improved color gen

This commit is contained in:
Yann Esposito (Yogsototh) 2021-09-06 15:39:07 +02:00
parent c3d52fe242
commit 6ba5d6c233
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -119,14 +119,14 @@
function hashcode(s){ function hashcode(s){
return s.split("").reduce( return s.split("").reduce(
function(acc,l){ function(acc,l){
acc = acc + (l.charCodeAt(0) - 'A'.charCodeAt(0)); acc = acc + 10 * (l.charCodeAt(0) - 'A'.charCodeAt(0));
return acc; return (acc % 256);
}, },
0); 0);
} }
function genColor(devname) { function genColor(devname) {
var h = 2.17*hashcode(devname) % 256; var h = hashcode(devname);
return "hsl(" + h + ",80%, 36%)"; return "hsl(" + h + ",80%, 36%)";
} }