Fix HSV.RGBA sector overflow

This commit is contained in:
Sasha Koshka 2024-08-15 16:51:36 -04:00
parent 0865c28965
commit acec0f6222

View File

@ -42,6 +42,8 @@ func (hsv HSV) RGBA () (r, g, b, a uint32) {
h := clamp01(hsv.H) * 360 h := clamp01(hsv.H) * 360
sector := int(h / 60) sector := int(h / 60)
// otherwise when given 1.0 for H, sector would overflow to 6
if sector > 5 { sector = 5 }
offset := (h / 60) - float64(sector) offset := (h / 60) - float64(sector)
p := component(v * (1 - s)) p := component(v * (1 - s))