function rainbow(size) {
    var i;
    var numcolors = 3; // 3 possible colors: r, x, b
    var colors = [
      255, // r
      0,   // x
      0    // b
    ];

    // generate a rainbow for all colors
    var addingcolor = true; // adding or subtracting color
    var r = [];
    for (var color = 0; color < numcolors * 2; color++) {
      // color will loop twice, so grab the lower digit
      var thecolor = (color + 2) % numcolors;

      // loop the possible values
      for (i = 0; i < 256; i++) {
        // set the color to i if adding, and 255 -i if subtracting
        colors[thecolor] = addingcolor ? i : 255 - i;

        // push a copy of the array
        r.push(colors.slice(0));
      }

      // flip the bit
      addingcolor = !addingcolor;
    }

    // only push what the user wanted, this si kinda gross
    var ret = [];
    var step = r.length / (size || r.length);
    for (i = 0; Math.ceil(i) < r.length; i += step) {
      ret.push((r[Math.round(i)] || r[Math.floor(i)]).slice(0));
    }
    return ret;
  }
/**
   * Generate an array that represents a rainbow of colors
   * in either RYB or RGB
   *
   * @param step {int} (optional) number of colors to step, defaults to 1 (normal iteration)
   *
   * returns an array of arrays like [[255,0,0],[255,0,1],[255,0,2],...]
   * with every possible color.
   */
Generate an array that represents a rainbow of colors
in either RYB or RGB

@param step {int} (optional) number of colors to step, defaults to 1 (normal iteration)


Generate an array that represents a rainbow of colors in either RYB or RGB @param step { int } ( optional ) number of colors to step defaults to 1 ( normal iteration )
function rainbow(size) {
    var i;
    var numcolors = 3; 
    var colors = [
      255, 
      0,   
      0    
    ];
    var addingcolor = true; 
    var r = [];
    for (var color = 0; color < numcolors * 2; color++) {
      var thecolor = (color + 2) % numcolors;
      for (i = 0; i < 256; i++) {
        colors[thecolor] = addingcolor ? i : 255 - i;
        r.push(colors.slice(0));
      }
      addingcolor = !addingcolor;
    }
    var ret = [];
    var step = r.length / (size || r.length);
    for (i = 0; Math.ceil(i) < r.length; i += step) {
      ret.push((r[Math.round(i)] || r[Math.floor(i)]).slice(0));
    }
    return ret;
  }
function rainbow ( size ) { var i ; var numcolors = 3 ; var colors = [ 255 , 0 , 0 ] ; var addingcolor = true ; var r = [ ] ; for ( var color = 0 ; color < numcolors * 2 ; color ++ ) { var thecolor = ( color + 2 ) % numcolors ; for ( i = 0 ; i < 256 ; i ++ ) { colors [ thecolor ] = addingcolor ? i : 255 - i ; r . push ( colors . slice ( 0 ) ) ; } addingcolor = ! addingcolor ; } var ret = [ ] ; var step = r . length / ( size || r . length ) ; for ( i = 0 ; Math . ceil ( i ) < r . length ; i += step ) { ret . push ( ( r [ Math . round ( i ) ] || r [ Math . floor ( i ) ] ) . slice ( 0 ) ) ; } return ret ; }
Generate an array that represents a rainbow of colors
 in either RYB or RGB
Generate an array that represents a rainbow of colors in either RYB or RGB
// 3 possible colors: r, x, b // r // x // b // generate a rainbow for all colors // adding or subtracting color // color will loop twice, so grab the lower digit // loop the possible values // set the color to i if adding, and 255 -i if subtracting // push a copy of the array // flip the bit // only push what the user wanted, this si kinda gross