-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkaleidoscope.dc
45 lines (39 loc) · 977 Bytes
/
kaleidoscope.dc
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
43
44
45
# run this in an 80x24 terminal
#
# usage: nice -19 dclang kaleidoscope.dc
# buffer size is 1921 (1920, but 1 extra slot for null character)
var mybuf
1921 mkbuf
mybuf !
# characters to choose from, right now, set to ' ' and '*'
32 1 !
42 2 !
32 3 !
: bufadd
over mybuf @ + swap 1 memset drop
;
: kaleidoscope
4096 times
0 # buffer offset, local on the stack
24 times
80 times
i 160 / 0.25 - dup * # This is all distance formula stuff:
j 48 / 0.25 - dup * # sqrt(a^2 + b^2)...distance from origin
+ sqrt sin # (sine of the distance from origin)
k 0.5 * * cos 0.5 * 0.51 + 2.9 * floor
1 + @ bufadd
1 + # increment the buffer offset
again
again
# add null char on buffer end
mybuf @ 1920 + 0 1 memset drop
# print the buffer
mybuf @ print
0.0384 sleep
drop
again
;
kaleidoscope
cr
"DONE!!!!!!" print
cr