I decided I wanted to be able to adjust color with a single slider like you would on the "hue" bar in GIMP ( or Photoshop or whatever ). The colors are created with a combination of Hue, Saturation, and Value. Instead of Red, Blue, Green.
So just in case somebody wants to do this too here is your function - h = hue , s = saturation, v = value, a = alpha
Function HSVAtoRGBA(h%,s%,v%,a%) As Integer
' Romans_I_XVI port (w/ a few tweaks) of:
' http://schinckel.net/2012/01/10/hsv-to-rgb-in-javascript/
h% = h% MOD 360
rgb = [ 0, 0, 0 ]
if s% = 0 then
rgb = [v%/100, v%/100, v%/100]
else
s = s%/100 : v = v%/100 : h = h%/60 : i = int(h)
data = [v*(1-s), v*(1-s*(h-i)), v*(1-s*(1-(h-i)))]
if i = 0 then
rgb = [v, data[2], data[0]]
else if i = 1 then
rgb = [data[1], v, data[0]]
else if i = 2 then
rgb = [data[0], v, data[2]]
else if i = 3 then
rgb = [data[0], data[1], v]
else if i = 4 then
rgb = [data[2], data[0], v]
else
rgb = [v, data[0], data[1]]
end if
end if
for c = 0 to rgb.count()-1 : rgb[c] = int(rgb[c] * 255) : end for
color% = (rgb[0] << 24) + (rgb[1] << 16) + (rgb[2] << 😎 + a%
return color%
End Function
I converted a Javascript function that I found to work for BrightScript.
Cheers.
Edit: I've changed the code to use dev42's code which solves the problem with the color getting clipped off at a baby blue and not continuing all the way back to red. Thank you very much Dev42!