mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
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:
@@ -5,6 +5,7 @@ package material
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"gioui.org/internal/f32color"
|
||||
"gioui.org/layout"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/paint"
|
||||
@@ -56,7 +57,7 @@ func (e EditorStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
if e.Editor.Len() > 0 {
|
||||
textColor := e.Color
|
||||
if disabled {
|
||||
textColor = mulAlpha(textColor, 150)
|
||||
textColor = f32color.MulAlpha(textColor, 150)
|
||||
}
|
||||
paint.ColorOp{Color: textColor}.Add(gtx.Ops)
|
||||
e.Editor.PaintText(gtx)
|
||||
|
||||
Reference in New Issue
Block a user