Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------
- -- HSV > RGB color conversion
- -----------------------------
- -- adapted from:
- -- http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
- -----------------------------
- function HSVtoRGB(h, s, v)
- local r, g, b
- local i = math.floor(h * 6)
- local f = h * 6 - i
- local p = v * (1 - s)
- local q = v * (1 - f * s)
- local t = v * (1 - (1 - f) * s)
- local switch = i % 6
- if switch == 0 then
- r = v g = t b = p
- elseif switch == 1 then
- r = q g = v b = p
- elseif switch == 2 then
- r = p g = v b = t
- elseif switch == 3 then
- r = p g = q b = v
- elseif switch == 4 then
- r = t g = p b = v
- elseif switch == 5 then
- r = v g = p b = q
- end
- return math.floor(r*255), math.floor(g*255), math.floor(b*255)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement