diff --git a/circleloop.go b/circleloop.go index e2048c0..c5ea017 100644 --- a/circleloop.go +++ b/circleloop.go @@ -21,11 +21,11 @@ func (cl *circleLoop) Generative(c *canva) { r := cl.radius var theta float64 = 0 - for i:=0; i mh { + hs.H = mh + } + + if hs.S > ms { + hs.S = ms + } + + if hs.V > mv { + hs.V = mv + } + + h, s, v := float64(hs.H)/float64(mh), float64(hs.S)/float64(ms), float64(hs.V)/float64(mv) + + var r, g, b float64 + if s == 0 { //HSV from 0 to 1 + r = v * 255 + g = v * 255 + b = v * 255 + } else { + h = h * 6 + if h == 6 { + h = 0 + } //H must be < 1 + i := math.Floor(h) //Or ... var_i = floor( var_h ) + v1 := v * (1 - s) + v2 := v * (1 - s*(h-i)) + v3 := v * (1 - s*(1-(h-i))) + + if i == 0 { + r = v + g = v3 + b = v1 + } else if i == 1 { + r = v2 + g = v + b = v1 + } else if i == 2 { + r = v1 + g = v + b = v3 + } else if i == 3 { + r = v1 + g = v2 + b = v + } else if i == 4 { + r = v3 + g = v1 + b = v + } else { + r = v + g = v1 + b = v2 + } + + r = r * 255 //RGB results from 0 to 255 + g = g * 255 + b = b * 255 + } + rgb := color.RGBA{ + R: uint8(r), + G: uint8(g), + B: uint8(b), + A: 0, + } + return rgb +} func ConvertCartesianToPixel(x, y, xaixs, yaixs float64, h, w int) (int, int) { xr, yr := x/xaixs, y/yaixs