optimize NRGBA conversion

This commit is contained in:
faiface 2017-01-04 19:02:12 +01:00
parent cafda2cfae
commit d52be83efe
1 changed files with 3 additions and 0 deletions

View File

@ -67,6 +67,9 @@ func (c NRGBA) RGBA() (r, g, b, a uint32) {
// NRGBAModel converts colors to NRGBA format.
var NRGBAModel = color.ModelFunc(func(c color.Color) color.Color {
if c, ok := c.(NRGBA); ok {
return c
}
r, g, b, a := c.RGBA()
if a == 0 {
return NRGBA{0, 0, 0, 0}