Files
gio/internal/f32color/rgba_test.go
T
Egon Elbre f114acdb02 widget: use correct color in Icon
iconvg seems to expect a linear premultiplied color.

Fixes gio#132

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2021-01-11 14:32:28 +01:00

39 lines
941 B
Go

// SPDX-License-Identifier: Unlicense OR MIT
package f32color
import (
"image/color"
"testing"
)
func TestNRGBAToRGBA_PostAlpha_Boundary(t *testing.T) {
for col := 0; col <= 0xFF; col++ {
for alpha := 0; alpha <= 0xFF; alpha++ {
in := color.NRGBA{R: uint8(col), A: uint8(alpha)}
premul := NRGBAToRGBA_PostAlpha(in)
if premul.A != uint8(alpha) {
t.Errorf("%v: got %v expected %v", in, premul.A, alpha)
}
if premul.R > premul.A {
t.Errorf("%v: R=%v > A=%v", in, premul.R, premul.A)
}
}
}
}
func TestNRGBAToLinearRGBA_Boundary(t *testing.T) {
for col := 0; col <= 0xFF; col++ {
for alpha := 0; alpha <= 0xFF; alpha++ {
in := color.NRGBA{R: uint8(col), A: uint8(alpha)}
premul := NRGBAToLinearRGBA(in)
if premul.A != uint8(alpha) {
t.Errorf("%v: got %v expected %v", in, premul.A, alpha)
}
if premul.R > premul.A {
t.Errorf("%v: R=%v > A=%v", in, premul.R, premul.A)
}
}
}
}