2016-11-24 08:13:05 -06:00
|
|
|
package pixel
|
|
|
|
|
|
|
|
import "image/color"
|
|
|
|
|
2016-11-24 09:06:33 -06:00
|
|
|
// colorToRGBA converts a color from image/color to RGBA components in interval [0, 1].
|
2016-12-01 10:54:27 -06:00
|
|
|
func colorToRGBA(c color.Color) (r, g, b, a float32) {
|
2016-11-24 08:13:05 -06:00
|
|
|
ri, gi, bi, ai := c.RGBA()
|
2016-12-01 10:54:27 -06:00
|
|
|
r = float32(ri) / 0xffff
|
|
|
|
g = float32(gi) / 0xffff
|
|
|
|
b = float32(bi) / 0xffff
|
|
|
|
a = float32(ai) / 0xffff
|
2016-11-24 08:13:05 -06:00
|
|
|
return
|
|
|
|
}
|