# HSB - Code for HSB to RGB

So I randomly decided to make a HSB to RGB thing. All you have to do is where you would put RGB values, put HSB(hue, sat, bri) and it will automatically convert to 3 RGB values (first r, then g, then b). Here is the only function you need:

``````function HSB(hue, sat, bri)
local h = hue % 360
local s = math.min(math.max(sat, 0), 100)
local b = math.min(math.max(bri, 0), 100)
local colr = color(0, 0, 0)
if h < 60 then
colr = color(255, h * (17 / 4), 0)
elseif h < 120 then
colr = color((120 - h) * (17 / 4), 255, 0)
elseif h < 180 then
colr = color(0, 255, (h - 120) * (17 / 4))
elseif h < 240 then
colr = color(0, (240 - h) * (17 / 4), 255)
elseif h < 300 then
colr = color((h - 240) * (17 / 4), 0, 255)
else
colr = color(255, 0, (360 - h) * (17 / 4))
end
colr = colr:mix(color(255, 255, 255), s / 100)
colr = colr:mix(color(0, 0, 0), b / 100)
colr = vec3(colr.r, colr.g, colr.b)
return colr:unpack()
end
``````

Simply copy the code, and paste in into whatever tab(s) you need!

There’s also lots of functions like this here if anyone’s interested (I remember finding these before and using them in some previous projects)