forked from joejulian/gio
all: use color.NRGBA in public API
color.RGBA has two problems with regards to using it. First the color values need to be premultiplied, whereas most APIs have non-premultiplied values. This is mainly to preserve color components with low alpha values. Second there are two ways to premultiply with sRGB. One is to premultiply after sRGB conversion, the other is before. This makes using the API more confusing. Using color.NRGBA in sRGB makes it align with CSS.e Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
@@ -19,8 +19,8 @@ import (
|
||||
|
||||
type SwitchStyle struct {
|
||||
Color struct {
|
||||
Enabled color.RGBA
|
||||
Disabled color.RGBA
|
||||
Enabled color.NRGBA
|
||||
Disabled color.NRGBA
|
||||
}
|
||||
Switch *widget.Bool
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Dimensions{Size: dims}
|
||||
}
|
||||
|
||||
func drawDisc(ops *op.Ops, sz float32, col color.RGBA) {
|
||||
func drawDisc(ops *op.Ops, sz float32, col color.NRGBA) {
|
||||
defer op.Push(ops).Pop()
|
||||
rr := sz / 2
|
||||
r := f32.Rectangle{Max: f32.Point{X: sz, Y: sz}}
|
||||
|
||||
Reference in New Issue
Block a user