Probably what you want is a random hue, but keeping the same brightness and saturation, and that function will help you. You will however need to extract the RGB values from the 24 bit number, which is a bit cryptic:
var c = E.HSBtoRGB(Math.random(),1,1);
colTo = [ (c&0xFF)/256, ((c>>8)&0xFF)/256, ((c>>16)&0xFF)/256 ];
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Sure - if you're doing that, it sounds like you don't need the
colors
array at all.[a,b,c]
Then, in the
if (colFade>=1)
if statement, replace what's there with:You could also look at using this function: http://www.espruino.com/Reference#l_E_HSBtoRGB
Probably what you want is a random hue, but keeping the same brightness and saturation, and that function will help you. You will however need to extract the RGB values from the 24 bit number, which is a bit cryptic: