Skip to content

Commit 3a0183b

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

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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 matrix(s) {
47+
const pattern = digitPatterns[s];
48+
return pattern.map((row) => row.map((cell) => (cell ? "🎃" : "🐈‍⬛")).join("")).join("\n");
49+
}
50+
51+
function range(n) {
52+
return Array.from({length: n}, (_, i) => i);
53+
}
54+
55+
const now = recho.now();
56+
57+
const digitPatterns = {
58+
0: [
59+
[0, 1, 1, 1, 0],
60+
[1, 0, 0, 0, 1],
61+
[1, 0, 0, 0, 1],
62+
[1, 0, 0, 0, 1],
63+
[1, 0, 0, 0, 1],
64+
[1, 0, 0, 0, 1],
65+
[0, 1, 1, 1, 0],
66+
],
67+
1: [
68+
[0, 0, 1, 0, 0],
69+
[0, 1, 1, 0, 0],
70+
[0, 0, 1, 0, 0],
71+
[0, 0, 1, 0, 0],
72+
[0, 0, 1, 0, 0],
73+
[0, 0, 1, 0, 0],
74+
[0, 1, 1, 1, 0],
75+
],
76+
2: [
77+
[0, 1, 1, 1, 0],
78+
[1, 0, 0, 0, 1],
79+
[0, 0, 0, 0, 1],
80+
[0, 0, 0, 1, 0],
81+
[0, 0, 1, 0, 0],
82+
[0, 1, 0, 0, 0],
83+
[1, 1, 1, 1, 1],
84+
],
85+
3: [
86+
[1, 1, 1, 1, 0],
87+
[0, 0, 0, 0, 1],
88+
[0, 0, 0, 0, 1],
89+
[0, 1, 1, 1, 0],
90+
[0, 0, 0, 0, 1],
91+
[0, 0, 0, 0, 1],
92+
[1, 1, 1, 1, 0],
93+
],
94+
4: [
95+
[0, 0, 0, 1, 0],
96+
[0, 0, 1, 1, 0],
97+
[0, 1, 0, 1, 0],
98+
[1, 0, 0, 1, 0],
99+
[1, 1, 1, 1, 1],
100+
[0, 0, 0, 1, 0],
101+
[0, 0, 0, 1, 0],
102+
],
103+
5: [
104+
[1, 1, 1, 1, 1],
105+
[1, 0, 0, 0, 0],
106+
[1, 1, 1, 1, 0],
107+
[0, 0, 0, 0, 1],
108+
[0, 0, 0, 0, 1],
109+
[0, 0, 0, 0, 1],
110+
[1, 1, 1, 1, 0],
111+
],
112+
6: [
113+
[0, 1, 1, 1, 0],
114+
[1, 0, 0, 0, 0],
115+
[1, 1, 1, 1, 0],
116+
[1, 0, 0, 0, 1],
117+
[1, 0, 0, 0, 1],
118+
[1, 0, 0, 0, 1],
119+
[0, 1, 1, 1, 0],
120+
],
121+
7: [
122+
[1, 1, 1, 1, 1],
123+
[0, 0, 0, 0, 1],
124+
[0, 0, 0, 1, 0],
125+
[0, 0, 1, 0, 0],
126+
[0, 1, 0, 0, 0],
127+
[0, 1, 0, 0, 0],
128+
[0, 1, 0, 0, 0],
129+
],
130+
8: [
131+
[0, 1, 1, 1, 0],
132+
[1, 0, 0, 0, 1],
133+
[1, 0, 0, 0, 1],
134+
[0, 1, 1, 1, 0],
135+
[1, 0, 0, 0, 1],
136+
[1, 0, 0, 0, 1],
137+
[0, 1, 1, 1, 0],
138+
],
139+
9: [
140+
[0, 1, 1, 1, 0],
141+
[1, 0, 0, 0, 1],
142+
[1, 0, 0, 0, 1],
143+
[0, 1, 1, 1, 1],
144+
[0, 0, 0, 0, 1],
145+
[1, 0, 0, 0, 1],
146+
[0, 1, 1, 1, 0],
147+
],
148+
":": [
149+
[0, 0, 0, 0, 0],
150+
[0, 0, 1, 0, 0],
151+
[0, 0, 1, 0, 0],
152+
[0, 0, 0, 0, 0],
153+
[0, 0, 1, 0, 0],
154+
[0, 0, 1, 0, 0],
155+
[0, 0, 0, 0, 0],
156+
],
157+
};

0 commit comments

Comments
 (0)