forked from joejulian/gio
internal/f32color: add colorspace-correct function for alpha scaling
Package material's ad-hoc mulAlpha didn't take the sRGB color-space into account, which meant that alpha-scaled colors were subtly wrong. Introduce f32color.MulAlpha and convert all uses to it. Thanks to René Post for finding and debugging the issue. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"image"
|
||||
"image/color"
|
||||
|
||||
"gioui.org/internal/f32color"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op/paint"
|
||||
@@ -42,7 +43,7 @@ func (c *checkable) layout(gtx layout.Context, checked bool) layout.Dimensions {
|
||||
size := gtx.Px(c.Size)
|
||||
icon.Color = c.IconColor
|
||||
if gtx.Queue == nil {
|
||||
icon.Color = mulAlpha(icon.Color, 150)
|
||||
icon.Color = f32color.MulAlpha(icon.Color, 150)
|
||||
}
|
||||
icon.Layout(gtx, unit.Px(float32(size)))
|
||||
return layout.Dimensions{
|
||||
|
||||
Reference in New Issue
Block a user