make rainbows

pull/1/head
ansuz 9 years ago
parent aa3880f442
commit 7102a0a164

@ -0,0 +1,29 @@
define([], function () {
return function (n) {
var r = 0.6,
n = n || 24, // default is 24 colours
i = 0,
t = [],
rgb = [0,2,4];
while(i<n)t.push(i++);
var colours = t.map(function (c, I) {
return '#'+ rgb.map(function (j) {
var x = ((Math.sin(r*(I+22)+j)*127+128) *0x01<<0)
.toString(16);
return x.length<2?"0"+x:x;
}).join("");
});
var J = 0;
return function () {
var j = J++;
if (colours[j]) {
return colours[j];
}
J = 0;
return colours[0];
};
};
});
Loading…
Cancel
Save