change hashbadge algorithm
This commit is contained in:
parent
81a8770140
commit
015b6926b8
1 changed files with 7 additions and 4 deletions
|
@ -21,6 +21,9 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hueRange = 60;
|
||||||
|
const hueCenter = 90 + bytes.length * 3;
|
||||||
|
|
||||||
let idx = 0;
|
let idx = 0;
|
||||||
function draw() {
|
function draw() {
|
||||||
const tmp = [];
|
const tmp = [];
|
||||||
|
@ -31,10 +34,10 @@
|
||||||
tmp.push(tmp[tmp.length - 1]);
|
tmp.push(tmp[tmp.length - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const r = (tmp[0]! / 128) * 255;
|
const h = (tmp[0] / 128) * hueRange + hueCenter - hueRange / 2;
|
||||||
const g = (tmp[1]! / 128) * 255;
|
const s = (tmp[1] / 128) * 100;
|
||||||
const b = (tmp[2]! / 128) * 255;
|
const l = (tmp[2] / 128) * 100;
|
||||||
ctx.fillStyle = `rgb(${r},${g},${b})`;
|
ctx.fillStyle = `hsl(${h},${s}%,${l}%)`;
|
||||||
ctx.fillRect(Math.floor(idx / BADGE_HEIGHT), idx % BADGE_HEIGHT, 1, 1);
|
ctx.fillRect(Math.floor(idx / BADGE_HEIGHT), idx % BADGE_HEIGHT, 1, 1);
|
||||||
idx++;
|
idx++;
|
||||||
if (bytes.length > 0) {
|
if (bytes.length > 0) {
|
||||||
|
|
Loading…
Reference in a new issue