Skip to content

Commit e2fc460

Browse files
committed
[Example] Halloween Clock (#188)
* Add halloween clock * Update pr numebr
1 parent 514c0c0 commit e2fc460

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
/**
2+
* @title Halloween Clock
3+
* @author Bairui Su
4+
* @created 2025-10-31
5+
* @pull_request 188
6+
* @github pearmini
7+
* @thumbnail_start 18
8+
*/
9+
10+
/**
11+
* ============================================================================
12+
* = Halloween Clock =
13+
* ============================================================================
14+
*
15+
* Recreated the Halloween Clock by Kirsten Allen.
16+
*
17+
* - https://codepen.io/kirstenallen/pen/PwZpoEN
18+
*/
19+
20+
//➜ 💀🎃🎃🎃💀💀🎃🎃🎃🎃💀💀💀💀💀💀💀💀💀💀💀🎃💀💀💀💀🎃💀💀💀💀💀💀💀💀💀💀💀💀🎃💀💀💀🎃🎃🎃💀💀
21+
//➜ 🎃💀💀💀🎃💀💀💀💀💀🎃💀💀💀🎃💀💀💀💀💀🎃🎃💀💀💀🎃🎃💀💀💀💀💀🎃💀💀💀💀💀🎃🎃💀💀🎃💀💀💀🎃💀
22+
//➜ 💀💀💀💀🎃💀💀💀💀💀🎃💀💀💀🎃💀💀💀💀🎃💀🎃💀💀💀💀🎃💀💀💀💀💀🎃💀💀💀💀🎃💀🎃💀💀🎃💀💀💀🎃💀
23+
//➜ 💀💀💀🎃💀💀💀🎃🎃🎃💀💀💀💀💀💀💀💀🎃💀💀🎃💀💀💀💀🎃💀💀💀💀💀💀💀💀💀🎃💀💀🎃💀💀💀🎃🎃🎃💀💀
24+
//➜ 💀💀🎃💀💀💀💀💀💀💀🎃💀💀💀🎃💀💀💀🎃🎃🎃🎃🎃💀💀💀🎃💀💀💀💀💀🎃💀💀💀🎃🎃🎃🎃🎃💀🎃💀💀💀🎃💀
25+
//➜ 💀🎃💀💀💀💀💀💀💀💀🎃💀💀💀🎃💀💀💀💀💀💀🎃💀💀💀💀🎃💀💀💀💀💀🎃💀💀💀💀💀💀🎃💀💀🎃💀💀💀🎃💀
26+
//➜ 🎃🎃🎃🎃🎃💀🎃🎃🎃🎃💀💀💀💀💀💀💀💀💀💀💀🎃💀💀💀🎃🎃🎃💀💀💀💀💀💀💀💀💀💀💀🎃💀💀💀🎃🎃🎃💀💀
27+
{
28+
const date = new Date(now);
29+
const h = date.getHours().toString().padStart(2, "0");
30+
const m = date.getMinutes().toString().padStart(2, "0");
31+
const s = date.getSeconds().toString().padStart(2, "0");
32+
const time = `${h}:${m}:${s}`;
33+
const buffer = range(7).map(() => range(6 * time.length).fill("💀"));
34+
for (let i = 0; i < time.length; i++) {
35+
const char = time[i];
36+
const pattern = digitPatterns[char];
37+
for (let j = 0; j < pattern.length; j++) {
38+
for (let k = 0; k < pattern[j].length; k++) {
39+
buffer[j][i * 6 + k] = pattern[j][k] ? "🎃" : "💀";
40+
}
41+
}
42+
}
43+
echo(buffer.map((row) => row.join("")).join("\n"));
44+
}
45+
46+
function range(n) {
47+
return Array.from({length: n}, (_, i) => i);
48+
}
49+
50+
const now = recho.now();
51+
52+
const digitPatterns = {
53+
0: [
54+
[0, 1, 1, 1, 0],
55+
[1, 0, 0, 0, 1],
56+
[1, 0, 0, 0, 1],
57+
[1, 0, 0, 0, 1],
58+
[1, 0, 0, 0, 1],
59+
[1, 0, 0, 0, 1],
60+
[0, 1, 1, 1, 0],
61+
],
62+
1: [
63+
[0, 0, 1, 0, 0],
64+
[0, 1, 1, 0, 0],
65+
[0, 0, 1, 0, 0],
66+
[0, 0, 1, 0, 0],
67+
[0, 0, 1, 0, 0],
68+
[0, 0, 1, 0, 0],
69+
[0, 1, 1, 1, 0],
70+
],
71+
2: [
72+
[0, 1, 1, 1, 0],
73+
[1, 0, 0, 0, 1],
74+
[0, 0, 0, 0, 1],
75+
[0, 0, 0, 1, 0],
76+
[0, 0, 1, 0, 0],
77+
[0, 1, 0, 0, 0],
78+
[1, 1, 1, 1, 1],
79+
],
80+
3: [
81+
[1, 1, 1, 1, 0],
82+
[0, 0, 0, 0, 1],
83+
[0, 0, 0, 0, 1],
84+
[0, 1, 1, 1, 0],
85+
[0, 0, 0, 0, 1],
86+
[0, 0, 0, 0, 1],
87+
[1, 1, 1, 1, 0],
88+
],
89+
4: [
90+
[0, 0, 0, 1, 0],
91+
[0, 0, 1, 1, 0],
92+
[0, 1, 0, 1, 0],
93+
[1, 0, 0, 1, 0],
94+
[1, 1, 1, 1, 1],
95+
[0, 0, 0, 1, 0],
96+
[0, 0, 0, 1, 0],
97+
],
98+
5: [
99+
[1, 1, 1, 1, 1],
100+
[1, 0, 0, 0, 0],
101+
[1, 1, 1, 1, 0],
102+
[0, 0, 0, 0, 1],
103+
[0, 0, 0, 0, 1],
104+
[0, 0, 0, 0, 1],
105+
[1, 1, 1, 1, 0],
106+
],
107+
6: [
108+
[0, 1, 1, 1, 0],
109+
[1, 0, 0, 0, 0],
110+
[1, 1, 1, 1, 0],
111+
[1, 0, 0, 0, 1],
112+
[1, 0, 0, 0, 1],
113+
[1, 0, 0, 0, 1],
114+
[0, 1, 1, 1, 0],
115+
],
116+
7: [
117+
[1, 1, 1, 1, 1],
118+
[0, 0, 0, 0, 1],
119+
[0, 0, 0, 1, 0],
120+
[0, 0, 1, 0, 0],
121+
[0, 1, 0, 0, 0],
122+
[0, 1, 0, 0, 0],
123+
[0, 1, 0, 0, 0],
124+
],
125+
8: [
126+
[0, 1, 1, 1, 0],
127+
[1, 0, 0, 0, 1],
128+
[1, 0, 0, 0, 1],
129+
[0, 1, 1, 1, 0],
130+
[1, 0, 0, 0, 1],
131+
[1, 0, 0, 0, 1],
132+
[0, 1, 1, 1, 0],
133+
],
134+
9: [
135+
[0, 1, 1, 1, 0],
136+
[1, 0, 0, 0, 1],
137+
[1, 0, 0, 0, 1],
138+
[0, 1, 1, 1, 1],
139+
[0, 0, 0, 0, 1],
140+
[1, 0, 0, 0, 1],
141+
[0, 1, 1, 1, 0],
142+
],
143+
":": [
144+
[0, 0, 0, 0, 0],
145+
[0, 0, 1, 0, 0],
146+
[0, 0, 1, 0, 0],
147+
[0, 0, 0, 0, 0],
148+
[0, 0, 1, 0, 0],
149+
[0, 0, 1, 0, 0],
150+
[0, 0, 0, 0, 0],
151+
],
152+
};

0 commit comments

Comments
 (0)