draw hashbadge via raf

feat/vaults
Tomáš Mládek 2021-12-19 19:27:37 +01:00
parent 36d3479f0d
commit 4ce227b82d
1 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,7 @@
}
let idx = 0;
while (bytes.length > 0) {
function draw() {
const tmp = [];
while (bytes.length > 0 && tmp.length < 3) {
tmp.push(bytes.shift());
@ -37,7 +37,12 @@
ctx.fillStyle = `rgb(${r},${g},${b})`;
ctx.fillRect(Math.floor(idx / BADGE_HEIGHT), idx % BADGE_HEIGHT, 1, 1);
idx++;
if (bytes.length > 0) {
requestAnimationFrame(draw);
}
}
requestAnimationFrame(draw);
});
</script>