HSV uses Premultiply and Unpremultiply functions
This commit is contained in:
parent
2b1f5d5c65
commit
9655da5841
@ -67,12 +67,7 @@ func (hsva HSVA) RGBA () (r, g, b, a uint32) {
|
||||
S: hsva.S,
|
||||
V: hsva.V,
|
||||
}.RGBA()
|
||||
a = uint32(hsva.A)
|
||||
// alpha premultiplication
|
||||
r = (r * a) / 0xFFFF
|
||||
g = (g * a) / 0xFFFF
|
||||
b = (b * a) / 0xFFFF
|
||||
return
|
||||
return Premultiply(r, g, b, uint32(hsva.A))
|
||||
}
|
||||
|
||||
// Canon returns the color but with the H, S, and V fields are constrained to
|
||||
@ -104,11 +99,7 @@ func hsvModel (c color.Color) color.Color {
|
||||
case HSV: return c
|
||||
case HSVA: return HSV { H: c.H, S: c.S, V: c.V }
|
||||
default:
|
||||
r, g, b, a := c.RGBA()
|
||||
// alpha unpremultiplication
|
||||
r = (r / a) * 0xFFFF
|
||||
g = (g / a) * 0xFFFF
|
||||
b = (b / a) * 0xFFFF
|
||||
r, g, b, _ := Unpremultiply(c.RGBA())
|
||||
return rgbToHSV(r, g, b)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user