Added a function to convert any color to color.RGBA

This commit is contained in:
Sasha Koshka 2024-06-26 10:40:22 -04:00
parent 14c4db9d16
commit b0108e6e0b

View File

@ -7,3 +7,14 @@ func Transparent (c color.Color) bool {
_, _, _, a := c.RGBA() _, _, _, a := c.RGBA()
return a != 0xFFFF return a != 0xFFFF
} }
// ToRGBA converts any color to a color.RGBA value.
func ToRGBA (c color.Color) color.RGBA {
r, g, b, a := c.RGBA()
return color.RGBA {
uint8(r >> 8),
uint8(g >> 8),
uint8(b >> 8),
uint8(a >> 8),
}
}