You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cryptpad/www/common/rainbow.js

30 lines
720 B
JavaScript

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];
};
};
});