-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.co
42 lines (38 loc) · 1.02 KB
/
index.co
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{innerWidth:width, innerHeight:height} = @
cols = width / 10 | 0
rows = height / 10 | 0
canvas <<<< { width, height }
ctx = canvas.getContext \2d
&translate width, 0
&scale -1 1
r = Math.random
write = (r! * 2 * rows | 0 for i til cols)
zero = (r! * 2 * rows | 0 for i til cols)
chars = ('' for i til cols)
step = ->
ctx.fillStyle = \#000
zero :=
for y, x of zero
ctx.fillRect x * 10, (y - 1) * 10, 10, 10
if r! * rows | 0
(y + 1) % (2 * rows)
else
r! * 2 * rows | 0
write :=
for y, x of write
# half width katakana
c = String.fromCharCode 12448 + r! * 96
ctx
&fillStyle = \#0f0
&fillText chars[x], x * 10, (y - 1) * 10
chars[x] = c
if r! * rows | 0
ctx
&fillStyle = \#000
&fillRect x * 10, (y - 1) * 10, 10, 10
&fillStyle = \#afa
&fillText c, x * 10, y * 10
(y + 1) % (2 * rows)
else
r! * 2 * rows | 0
setInterval step, 33