From 015b6926b8ba84238a75327990244f9b5ab04e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Tue, 21 Dec 2021 22:31:37 +0100 Subject: [PATCH] change hashbadge algorithm --- ui/src/components/display/HashBadge.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/src/components/display/HashBadge.svelte b/ui/src/components/display/HashBadge.svelte index ecca6b9..8501e43 100644 --- a/ui/src/components/display/HashBadge.svelte +++ b/ui/src/components/display/HashBadge.svelte @@ -21,6 +21,9 @@ return; } + const hueRange = 60; + const hueCenter = 90 + bytes.length * 3; + let idx = 0; function draw() { const tmp = []; @@ -31,10 +34,10 @@ tmp.push(tmp[tmp.length - 1]); } - const r = (tmp[0]! / 128) * 255; - const g = (tmp[1]! / 128) * 255; - const b = (tmp[2]! / 128) * 255; - ctx.fillStyle = `rgb(${r},${g},${b})`; + const h = (tmp[0] / 128) * hueRange + hueCenter - hueRange / 2; + const s = (tmp[1] / 128) * 100; + const l = (tmp[2] / 128) * 100; + ctx.fillStyle = `hsl(${h},${s}%,${l}%)`; ctx.fillRect(Math.floor(idx / BADGE_HEIGHT), idx % BADGE_HEIGHT, 1, 1); idx++; if (bytes.length > 0) {