functionrainbow(num){ var num = num || 12; var step = 1 / (num/3); var colors = [];
for(var i =0; i<num; i++){ var r = channelColor(i*step*2 + 2); var g = channelColor(i*step*2); var b = channelColor(i*step*2 + 4); colors.push([r*255, g*255, b*255]); }
functionchannelColor(num) {//0-1 inclement; 1-3 keep top, 3-4 declement, 4-6 keep bot; /*outPut 0-1*/ while(num >= 6){ num = num-6 } if(num >=0 && num <1) return num; if(num >=1 && num <=3) return1; if(num >3 && num <4) return1-(num%1); if(num >=4 && num <6) return0; }