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
|
|
|
|
}
|
2024-06-26 08:40:22 -06:00
|
|
|
|
|
|
|
// 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),
|
|
|
|
}
|
|
|
|
}
|