Update color picker code in response to HSV color changes
This commit is contained in:
parent
2546c338ad
commit
0865c28965
@ -44,7 +44,7 @@ func NewColorPicker (value color.Color) *ColorPicker {
|
|||||||
picker.alphaSlider = NewVerticalSlider(0.0)
|
picker.alphaSlider = NewVerticalSlider(0.0)
|
||||||
picker.Add(picker.alphaSlider)
|
picker.Add(picker.alphaSlider)
|
||||||
picker.alphaSlider.OnValueChange(func () {
|
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.on.valueChange.Broadcast()
|
||||||
picker.pickerMap.Invalidate()
|
picker.pickerMap.Invalidate()
|
||||||
})
|
})
|
||||||
@ -62,7 +62,7 @@ func (this *ColorPicker) Value () color.Color {
|
|||||||
// SetValue sets the color of the picker.
|
// SetValue sets the color of the picker.
|
||||||
func (this *ColorPicker) SetValue (value color.Color) {
|
func (this *ColorPicker) SetValue (value color.Color) {
|
||||||
if value == nil { value = color.Transparent }
|
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.hueSlider.SetValue(this.value.H)
|
||||||
this.alphaSlider.SetValue(float64(this.value.A) / 255)
|
this.alphaSlider.SetValue(float64(this.value.A) / 255)
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ func (this *colorPickerMap) Draw (can canvas.Canvas) {
|
|||||||
H: this.parent.value.H,
|
H: this.parent.value.H,
|
||||||
S: float64(xx) / float64(bounds.Dx()),
|
S: float64(xx) / float64(bounds.Dx()),
|
||||||
V: 1 - float64(yy) / float64(bounds.Dy()),
|
V: 1 - float64(yy) / float64(bounds.Dy()),
|
||||||
A: 255,
|
A: 0xFFFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
sPos := int( this.parent.value.S * float64(bounds.Dx()))
|
sPos := int( this.parent.value.S * float64(bounds.Dx()))
|
||||||
|
Loading…
Reference in New Issue
Block a user