You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Sure - if you're doing that, it sounds like you don't need the colors array at all.

    • set colFrom to [0,0,0] - to start the sequence from black
    • set colFade to 0 (to reset the fade to start from the beginning)
    • set colTo to [a,b,c]
    • Then, in the if (colFade>=1) if statement, replace what's there with:

      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_HS­BtoRGB

    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 ];
    
About

Avatar for Gordon @Gordon started