最后活跃于 1733956154

A small box drawing program, driven by a pen plotter DSL.

修订 1fe912be5b1d7bec3a9ef33a8612c9cc27e565dd

Drawing A Box 原始文件 Playground
1|u | up
2|d | down
3|l | left
4|r | right
5|f | forward
6|tl | turn left
7|tr | turn right
8|uu | u,u
9|dd | d,d
10|ll | l,l
11|rr | r,r
12|ff | f,f
13|tll | tl,tl
14|trr | tr,tr
15|uuu | uu,u
16|ddd | dd,d
17|lll | ll,l
18|rrr | rr,r
19|fff | ff,f
20|tlll | tll,tl
21|trrr | trr,tr
22|uuuu | uu,uu
23|dddd | dd,dd
24|llll | ll,ll
25|rrrr | rr,rr
26|ffff | ff,ff
27|tllll | tll,tll
28|trrrr | trr,trr
29|up | @pen-up
30|down | @pen-down
31|left | @pen-left
32|right | @pen-right
33|forward | @pen-forward
34|turn left | @pen-turn-left
35|turn right| @pen-turn-right
36|pen down | @pen-start
37|pen up | @pen-stop
38
39|@pen-start| @pen-draw
40|@pen-stop, @pen-draw| @pen-stop
41|@pen-stop|
42
43||@pen-direction-right
44|@pen-forward, @pen-direction-up | @pen-up, @pen-direction-up
45|@pen-forward, @pen-direction-down | @pen-down, @pen-direction-down
46|@pen-forward, @pen-direction-left | @pen-left, @pen-direction-left
47|@pen-forward, @pen-direction-right| @pen-right, @pen-direction-right
48
49|@pen-turn-left, @pen-direction-up | @pen-direction-left
50|@pen-turn-left, @pen-direction-down | @pen-direction-right
51|@pen-turn-left, @pen-direction-left | @pen-direction-down
52|@pen-turn-left, @pen-direction-right| @pen-direction-up
53
54|@pen-turn-right, @pen-direction-up | @pen-direction-right
55|@pen-turn-right, @pen-direction-down | @pen-direction-left
56|@pen-turn-right, @pen-direction-left | @pen-direction-up
57|@pen-turn-right, @pen-direction-right| @pen-direction-down
58
59|@pen-lift, @pen-draw| @pen-lift
60|@pen-lift|
61
62|#| constant, @pixel-x = @pen-x, 18446744073709551615
63|#| constant, @pixel-y = @pen-y, 18446744073709551615
64|#| constant, @pen-x <- @pen-x-temp, 18446744073709551615
65|#| constant, @pen-y <- @pen-y-temp, 18446744073709551615
66|@pixel-x = @pen-x:max| @pixel-x = @pen-x:18446744073709551615
67|@pixel-y = @pen-y:max| @pixel-y = @pen-y:18446744073709551615
68|@pen-x <- @pen-x-temp:max| @pen-x <- @pen-x-temp:18446744073709551615
69|@pen-y <- @pen-y-temp:max| @pen-y <- @pen-y-temp:18446744073709551615
70
71|@pixel-x = @pen-x, @pen-x | @pen-x-temp,
72 @pixel-x,
73 @pixel-x = @pen-x
74|@pixel-x = @pen-x | @pen-x <- @pen-x-temp
75|@pen-x <- @pen-x-temp, @pen-x-temp | @pen-x, @pen-x <- @pen-x-temp
76|@pen-x <- @pen-x-temp |
77
78|@pixel-y = @pen-y, @pen-y | @pen-y-temp,
79 @pixel-y,
80 @pixel-y = @pen-y
81|@pixel-y = @pen-y | @pen-y <- @pen-y-temp
82|@pen-y <- @pen-y-temp, @pen-y-temp | @pen-y, @pen-y <- @pen-y-temp
83|@pen-y <- @pen-y-temp |
84
85|@trigger-set-pixel| @pixel-r += 255, @pixel-g += 255, @pixel-b += 255, set pixel
86|set pixel| @set-pixel
87
88|@pen-x++| @pen-x
89|@pen-x--, @pen-x|
90|@pen-x--|
91
92|@pen-y++| @pen-y
93|@pen-y--, @pen-y|
94|@pen-y--|
95
96|@pen-left, @pen-draw|
97 @pixel-x = @pen-x:max,
98 @pixel-y = @pen-y:max,
99 @pen-draw,
100 @trigger-set-pixel,
101 @pen-x--
102
103|@pen-left|
104 @pen-x--
105
106|@pen-right, @pen-draw|
107 @pixel-x = @pen-x:max,
108 @pixel-y = @pen-y:max,
109 @pen-draw,
110 @trigger-set-pixel,
111 @pen-x++
112
113|@pen-right|
114 @pen-x++
115
116|@pen-up, @pen-draw|
117 @pixel-x = @pen-x:max,
118 @pixel-y = @pen-y:max,
119 @pen-draw,
120 @trigger-set-pixel,
121 @pen-y--
122
123|@pen-up|
124 @pen-y--
125
126|@pen-down, @pen-draw|
127 @pixel-x = @pen-x:max,
128 @pixel-y = @pen-y:max,
129 @pen-draw,
130 @trigger-set-pixel,
131 @pen-y++
132
133|@pen-down|
134 @pen-y++
135
136
137
138
139|| start
140|start|
141 set up the screen,
142 pen up,
143 rrrr,rrrr,rrrr,rrrr,
144 dddd,dddd,dddd,dddd,
145 main
146|set up the screen|
147 @resolution-x += 255,
148 @resolution-x += 255,
149 @resolution-y += 255,
150 @resolution-y += 255,
151 set the screen resolution
152|set the screen resolution| @set-resolution
153|main|
154 poll for input,
155 clear the screen,
156 draw a frame,
157 display,
158 loop
159|poll for input| @poll-input
160|clear the screen| @clear-screen
161|draw a frame|1
162|1|2, pen down, rrrr, rrrr, rrrr, rrrr
163|2|3, dddd, dddd, dddd, dddd
164|3|4, llll, llll, llll, llll
165|4|5, uuuu, uuuu, uuuu, uuuu
166|5| , pen up, r, d
167|display| @display
168|loop, @quit|
169|loop| main
170