|
| 1 | +// Bangle.js 2 - Binary Leet ClockZ |
| 2 | +/* |
| 3 | +
|
| 4 | +bangle.js2: create binary 'leet clock' where the time is shown as text |
| 5 | +"leet clockz" with binary 0 being normal character and binary one |
| 6 | +being leet translation. Be careful to only update time on minute |
| 7 | +boundaries. |
| 8 | +
|
| 9 | +So yeah — 1337 c10ckZ = certified leetspeak 😎 |
| 10 | + |
| 11 | +ChatGPT said: |
| 12 | +Alright, here’s a hardcore hacker variant of elite clock in full-on aggressive leetspeak: |
| 13 | +
|
| 14 | +£|173 ¢|_0¢|<Z |
| 15 | +
|
| 16 | +Breakdown: |
| 17 | +
|
| 18 | +E → £ or 3 |
| 19 | +L → | or £ |
| 20 | +I → 1 or ! |
| 21 | +T → 7 or + |
| 22 | +C → ¢ or ( |
| 23 | +O → 0 |
| 24 | +K → |< or X |
| 25 | +
|
| 26 | +Other extreme variants: |
| 27 | +3|173 (|_0(<Z |
| 28 | +€|!73 ©|0xX |
| 29 | +3L1+3 (L0XXZ |
| 30 | +
|
| 31 | + */ |
| 32 | + |
| 33 | +const TEXT = "leet\nclockz"; |
| 34 | +const LEET = { |
| 35 | + "l": "1", |
| 36 | + "e": "3", |
| 37 | + "t": "7", |
| 38 | + " ": " ", |
| 39 | + "c": "(", |
| 40 | + "o": "0", |
| 41 | + "k": "X", |
| 42 | + "z": "2" |
| 43 | +}; |
| 44 | + |
| 45 | +// Convert hour (12h) and minute to binary mask |
| 46 | +function getBinaryFromTime(d) { |
| 47 | + let h = d.getHours() % 12; |
| 48 | + if (h === 0) h = 12; // 12-hour format: 0 becomes 12 |
| 49 | + const m = d.getMinutes(); |
| 50 | + const bin = ((h << 7) | m).toString(2).padStart(11, '0'); |
| 51 | + return bin; |
| 52 | +} |
| 53 | + |
| 54 | +// Map normal characters to leet if binary mask says so |
| 55 | +function getDisplayText(binMask) { |
| 56 | + return TEXT.split("").map((ch, i) => |
| 57 | + binMask[i] === '1' ? (LEET[ch] || ch) : ch |
| 58 | + ).join(""); |
| 59 | +} |
| 60 | + |
| 61 | +function draw() { |
| 62 | + g.reset().clear(); |
| 63 | + const now = new Date(); |
| 64 | + const bin = getBinaryFromTime(now); |
| 65 | + const txt = getDisplayText(bin); |
| 66 | + |
| 67 | + const w = 0; |
| 68 | + g.setFont("Vector", 47).setFontAlign(0,0); |
| 69 | + |
| 70 | + g.drawString(txt, (g.getWidth() - w) / 2, (g.getHeight() - 0) / 2); |
| 71 | +} |
| 72 | + |
| 73 | +function scheduleNextDraw() { |
| 74 | + const now = new Date(); |
| 75 | + const msToNextMin = 60000 - (now.getSeconds() * 1000 + now.getMilliseconds()); |
| 76 | + setTimeout(() => { |
| 77 | + draw(); |
| 78 | + scheduleNextDraw(); |
| 79 | + }, msToNextMin); |
| 80 | +} |
| 81 | + |
| 82 | +// Init |
| 83 | +draw(); |
| 84 | +scheduleNextDraw(); |
| 85 | +//Bangle.loadWidgets(); |
| 86 | +//Bangle.drawWidgets(); |
0 commit comments