Sure - if you're doing that, it sounds like you don't need the colors array at all.
colFade = 0; // restart fade again
colFrom = colTo; // fade from what we faded *to* last time
colTo = [....]; // your random values
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:
var c = E.HSBtoRGB(Math.random(),1,1);
colTo = [ (c&0xFF)/256, ((c>>8)&0xFF)/256, ((c>>16)&0xFF)/256 ];
© Espruino, powered by microcosm.
Report a problem