optimize color.NRGBA -> pixel.NRGBA conversion

This commit is contained in:
faiface 2017-03-19 20:09:05 +01:00
parent 0b5c3f2171
commit 1be88eeb17
1 changed files with 8 additions and 0 deletions

View File

@ -82,6 +82,14 @@ func nrgbaModel(c color.Color) color.Color {
if c, ok := c.(NRGBA); ok {
return c
}
if c, ok := c.(color.NRGBA); ok {
return NRGBA{
R: float64(c.R) / 255,
G: float64(c.G) / 255,
B: float64(c.B) / 255,
A: float64(c.A) / 255,
}
}
r, g, b, a := c.RGBA()
if a == 0 {
return NRGBA{0, 0, 0, 0}