From ac1a952b40bafb1d2585da0e2e957e89915533cb Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 5 Sep 2024 22:46:58 -0400 Subject: [PATCH] Move color functionality into subpackage of internal --- colorpicker.go | 8 ++++---- internal/{ => color}/color.go | 2 +- swatch.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename internal/{ => color}/color.go (99%) diff --git a/colorpicker.go b/colorpicker.go index a848e3d..bd554bc 100644 --- a/colorpicker.go +++ b/colorpicker.go @@ -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()), diff --git a/internal/color.go b/internal/color/color.go similarity index 99% rename from internal/color.go rename to internal/color/color.go index 41abd7c..f96b0b9 100644 --- a/internal/color.go +++ b/internal/color/color.go @@ -1,4 +1,4 @@ -package internal +package color import "fmt" import "image/color" diff --git a/swatch.go b/swatch.go index 61a4df6..e3065c3 100644 --- a/swatch.go +++ b/swatch.go @@ -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) })