main.go: broken WIP for HSV

This commit is contained in:
Codeberg 2019-05-28 12:15:47 +02:00 committed by Holger Waechtler
parent 6e230cfb44
commit 62d613358a

15
main.go
View File

@ -100,20 +100,21 @@ func rgb(s string) *RGB {
} }
func (c *HSV) to_rgb() *RGB { func (c *HSV) to_rgb() *RGB {
h := int(floor(c.h / 60)) h := int((c.h / 60))
f := c.h / 60 - h f := c.h / 60 - h
p := c.v * (1 - c.s) p := c.v * (1 - c.s)
q := c.v * (1 - c.s * f) q := c.v * (1 - c.s * f)
t := c.v * (1 - c.s * (1 - f)) t := c.v * (1 - c.s * (1 - f))
switch (h) { switch (h) {
case 6: case 6:
case 0: return f2rgb(C.V, t, p) case 0: return f2rgb(c.v, t, p)
case 1: return f2rgb(q, C.V, p) case 1: return f2rgb(q, c.v, p)
case 2: return f2rgb(p, C.V, t) case 2: return f2rgb(p, c.v, t)
case 3: return f2rgb(p, q, C.V) case 3: return f2rgb(p, q, c.v)
case 4: return f2rgb(t, p, C.V) case 4: return f2rgb(t, p, c.v)
case 5: return f2rgb(C.V, p, q) case 5: return f2rgb(c.v, p, q)
} }
return f2rgb(0, 0, 0)
} }
func add255(x uint8, y uint8) uint8 { func add255(x uint8, y uint8) uint8 {