Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

updtae hash color

+47
+47
system/public/aesthetic.computer/disks/common/hash-color.mjs
··· 1 + // hash-color, 2025.3.30 2 + // Per-character color identity for git commit hashes. 3 + // Each hex digit (0-f) maps to a distinct hue, producing a 4 + // colorful "fingerprint" that makes hashes visually recognizable. 5 + 6 + // 16 hand-tuned colors for hex digits 0-f, ensuring good contrast 7 + // on both dark and light backgrounds. 8 + const HEX_COLORS = { 9 + "0": [255, 100, 100], // red 10 + "1": [255, 160, 80], // orange 11 + "2": [255, 210, 70], // gold 12 + "3": [200, 230, 80], // lime 13 + "4": [100, 220, 100], // green 14 + "5": [80, 210, 180], // teal 15 + "6": [80, 200, 230], // sky 16 + "7": [100, 160, 255], // blue 17 + "8": [140, 130, 255], // indigo 18 + "9": [180, 110, 255], // violet 19 + a: [220, 100, 240], // purple 20 + b: [255, 100, 200], // magenta 21 + c: [255, 130, 150], // rose 22 + d: [200, 180, 140], // tan 23 + e: [160, 210, 200], // sage 24 + f: [220, 200, 255], // lavender 25 + }; 26 + 27 + // Returns a color-code string for MatrixChunky8/write: \r,g,b\char 28 + // e.g. "a1b" → "\220,100,240\a\255,160,80\1\255,100,200\b" 29 + function colorizeHash(hash) { 30 + let out = ""; 31 + for (const ch of hash) { 32 + const c = HEX_COLORS[ch.toLowerCase()]; 33 + if (c) { 34 + out += `\\${c[0]},${c[1]},${c[2]}\\${ch}`; 35 + } else { 36 + out += ch; 37 + } 38 + } 39 + return out; 40 + } 41 + 42 + // Returns the RGB array for a single hex digit. 43 + function hashCharColor(ch) { 44 + return HEX_COLORS[ch.toLowerCase()] || [200, 200, 200]; 45 + } 46 + 47 + export { colorizeHash, hashCharColor, HEX_COLORS };