Compare commits

..

No commits in common. "6bfa97e6aaf6744bf00c7a6838702eb0436a14bf" and "ad5efe57d4dc7b49dec848ba9eafd26062d52c85" have entirely different histories.

3 changed files with 4 additions and 21 deletions

2
go.mod
View File

@ -1,3 +1,3 @@
module git.tebibyte.media/sashakoshka/goutil
go 1.20.0
go 1.21.0

View File

@ -22,9 +22,9 @@ func ToRGBA (c color.Color) color.RGBA {
// Premultiply applies alpha-premultiplication that colors must apply as per
// color.Color.RGBA. This is an intrinsically lossy proccess.
func Premultiply (ur, ug, ub, ua uint32) (r, g, b, a uint32) {
return (ur * ua) / 0xFFFF,
(ug * ua) / 0xFFFF,
(ub * ua) / 0xFFFF,
return (ur * a) / 0xFFFF,
(ug * a) / 0xFFFF,
(ub * a) / 0xFFFF,
ua
}

View File

@ -1,17 +0,0 @@
package ucolor
import "testing"
func TestPremultiply (test *testing.T) {
r, g, b, a := Premultiply(0xFFFF, 0xFFFF, 0xFFFF, 0x8888)
if r != 0x8888 || g != 0x8888 || b != 0x8888 || a != 0x8888 {
test.Fatalf("wrong value: %08x %08x %08x %08x", r, g, b, a)
}
}
func TestUnpremultiply (test *testing.T) {
r, g, b, a := Unpremultiply(0x8888, 0x8888, 0x8888, 0x8888)
if r != 0xFFFF || g != 0xFFFF || b != 0xFFFF || a != 0x8888 {
test.Fatalf("wrong value: %08x %08x %08x %08x", r, g, b, a)
}
}