Move color functionality into subpackage of internal
This commit is contained in:
parent
45a6634e73
commit
ac1a952b40
@ -6,7 +6,7 @@ import "git.tebibyte.media/tomo/tomo/input"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
import "git.tebibyte.media/tomo/objects/layouts"
|
||||
import "git.tebibyte.media/tomo/objects/internal"
|
||||
import icolor "git.tebibyte.media/tomo/objects/internal/color"
|
||||
|
||||
var _ tomo.Object = new(HSVAColorPicker)
|
||||
|
||||
@ -18,7 +18,7 @@ var _ tomo.Object = new(HSVAColorPicker)
|
||||
// saturation and the Y axis controls value.
|
||||
type HSVAColorPicker struct {
|
||||
box tomo.ContainerBox
|
||||
value internal.HSVA
|
||||
value icolor.HSVA
|
||||
|
||||
pickerMap *hsvaColorPickerMap
|
||||
hueSlider *Slider
|
||||
@ -80,7 +80,7 @@ func (this *HSVAColorPicker) Value () color.Color {
|
||||
// SetValue sets the color of the picker.
|
||||
func (this *HSVAColorPicker) SetValue (value color.Color) {
|
||||
if value == nil { value = color.Transparent }
|
||||
this.value = internal.HSVAModel.Convert(value).(internal.HSVA)
|
||||
this.value = icolor.HSVAModel.Convert(value).(icolor.HSVA)
|
||||
this.hueSlider.SetValue(this.value.H)
|
||||
this.alphaSlider.SetValue(float64(this.value.A) / 0xFFFF)
|
||||
this.pickerMap.Invalidate()
|
||||
@ -152,7 +152,7 @@ func (this *hsvaColorPickerMap) Draw (can canvas.Canvas) {
|
||||
xx := x - bounds.Min.X
|
||||
yy := y - bounds.Min.Y
|
||||
|
||||
pixel := internal.HSVA {
|
||||
pixel := icolor.HSVA {
|
||||
H: this.parent.value.H,
|
||||
S: float64(xx) / float64(bounds.Dx()),
|
||||
V: 1 - float64(yy) / float64(bounds.Dy()),
|
||||
|
@ -1,4 +1,4 @@
|
||||
package internal
|
||||
package color
|
||||
|
||||
import "fmt"
|
||||
import "image/color"
|
@ -8,7 +8,7 @@ import "git.tebibyte.media/tomo/tomo/input"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
import "git.tebibyte.media/tomo/objects/layouts"
|
||||
import "git.tebibyte.media/tomo/objects/internal"
|
||||
import icolor "git.tebibyte.media/tomo/objects/internal/color"
|
||||
|
||||
var _ tomo.Object = new(Swatch)
|
||||
|
||||
@ -117,7 +117,7 @@ func (this *Swatch) Choose () {
|
||||
|
||||
updateHexInput := func () {
|
||||
nrgba := color.NRGBAModel.Convert(colorPicker.Value()).(color.NRGBA)
|
||||
hexInput.SetValue(internal.FormatNRGBA(nrgba))
|
||||
hexInput.SetValue(icolor.FormatNRGBA(nrgba))
|
||||
}
|
||||
updateHexInput()
|
||||
commit := func () {
|
||||
@ -130,7 +130,7 @@ func (this *Swatch) Choose () {
|
||||
})
|
||||
hexInput.OnConfirm(commit)
|
||||
hexInput.OnValueChange(func () {
|
||||
nrgba := internal.ParseNRGBA(hexInput.Value())
|
||||
nrgba := icolor.ParseNRGBA(hexInput.Value())
|
||||
this.userSetValue(nrgba)
|
||||
colorPicker.SetValue(nrgba)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user