feat: add a way to set color from hsv

This commit is contained in:
Kazhnuz 2021-04-25 16:27:20 +02:00
parent 2d1ea4c2a0
commit f7afcdd5a9

View file

@ -27,6 +27,22 @@ local Graphics = {}
-- COLOR FUNCTIONS
-- Handle colors and scene colors
function Graphics.setColorHSV(h, s, v)
if s <= 0 then return v,v,v end
h, s, v = h*6, s, v
local c = v*s
local x = (1-math.abs((h%2)-1))*c
local m,r,g,b = (v-c), 0,0,0
if h < 1 then r,g,b = c,x,0
elseif h < 2 then r,g,b = x,c,0
elseif h < 3 then r,g,b = 0,c,x
elseif h < 4 then r,g,b = 0,x,c
elseif h < 5 then r,g,b = x,0,c
else r,g,b = c,0,x
end
love.graphics.setColor((r+m),(g+m),(b+m),1)
end
function Graphics.resetColor()
love.graphics.setColor(1,1,1,1)
end