goutil/image/color/color.go

21 lines
400 B
Go
Raw Normal View History

2024-06-23 06:45:58 -06:00
package ucolor
import "image/color"
// Transparent returns whether or not a color has transparency.
func Transparent (c color.Color) bool {
_, _, _, a := c.RGBA()
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),
}
}