Update color picker code in response to HSV color changes

This commit is contained in:
Sasha Koshka 2024-08-15 16:42:31 -04:00
parent 2546c338ad
commit 0865c28965

View File

@ -44,7 +44,7 @@ func NewColorPicker (value color.Color) *ColorPicker {
picker.alphaSlider = NewVerticalSlider(0.0)
picker.Add(picker.alphaSlider)
picker.alphaSlider.OnValueChange(func () {
picker.value.A = uint8(picker.alphaSlider.Value() * 255)
picker.value.A = uint16(picker.alphaSlider.Value() * 0xFFFF)
picker.on.valueChange.Broadcast()
picker.pickerMap.Invalidate()
})
@ -62,7 +62,7 @@ func (this *ColorPicker) Value () color.Color {
// SetValue sets the color of the picker.
func (this *ColorPicker) SetValue (value color.Color) {
if value == nil { value = color.Transparent }
this.value = internal.RGBAToHSVA(value.RGBA())
this.value = internal.HSVAModel.Convert(value).(internal.HSVA)
this.hueSlider.SetValue(this.value.H)
this.alphaSlider.SetValue(float64(this.value.A) / 255)
}
@ -137,7 +137,7 @@ func (this *colorPickerMap) Draw (can canvas.Canvas) {
H: this.parent.value.H,
S: float64(xx) / float64(bounds.Dx()),
V: 1 - float64(yy) / float64(bounds.Dy()),
A: 255,
A: 0xFFFF,
}
sPos := int( this.parent.value.S * float64(bounds.Dx()))