Drawing A Box
· 3.9 KiB · Text
Исходник
Playground
|u | up
|d | down
|l | left
|r | right
|f | forward
|tl | turn left
|tr | turn right
|uu | u,u
|dd | d,d
|ll | l,l
|rr | r,r
|ff | f,f
|tll | tl,tl
|trr | tr,tr
|uuu | uu,u
|ddd | dd,d
|lll | ll,l
|rrr | rr,r
|fff | ff,f
|tlll | tll,tl
|trrr | trr,tr
|uuuu | uu,uu
|dddd | dd,dd
|llll | ll,ll
|rrrr | rr,rr
|ffff | ff,ff
|tllll | tll,tll
|trrrr | trr,trr
|up | @pen-up
|down | @pen-down
|left | @pen-left
|right | @pen-right
|forward | @pen-forward
|turn left | @pen-turn-left
|turn right| @pen-turn-right
|pen down | @pen-start
|pen up | @pen-stop
|@pen-start| @pen-draw
|@pen-stop, @pen-draw| @pen-stop
|@pen-stop|
||@pen-direction-right
|@pen-forward, @pen-direction-up | @pen-up, @pen-direction-up
|@pen-forward, @pen-direction-down | @pen-down, @pen-direction-down
|@pen-forward, @pen-direction-left | @pen-left, @pen-direction-left
|@pen-forward, @pen-direction-right| @pen-right, @pen-direction-right
|@pen-turn-left, @pen-direction-up | @pen-direction-left
|@pen-turn-left, @pen-direction-down | @pen-direction-right
|@pen-turn-left, @pen-direction-left | @pen-direction-down
|@pen-turn-left, @pen-direction-right| @pen-direction-up
|@pen-turn-right, @pen-direction-up | @pen-direction-right
|@pen-turn-right, @pen-direction-down | @pen-direction-left
|@pen-turn-right, @pen-direction-left | @pen-direction-up
|@pen-turn-right, @pen-direction-right| @pen-direction-down
|@pen-lift, @pen-draw| @pen-lift
|@pen-lift|
|@pixel-x = @pen-x:max| @pixel-x = @pen-x:4294967295
|@pixel-y = @pen-y:max| @pixel-y = @pen-y:4294967295
|@pen-x <- @pen-x-temp:max| @pen-x <- @pen-x-temp:4294967295
|@pen-y <- @pen-y-temp:max| @pen-y <- @pen-y-temp:4294967295
|@pixel-x = @pen-x, @pen-x | @pen-x-temp,
@pixel-x,
@pixel-x = @pen-x
|@pixel-x = @pen-x | @pen-x <- @pen-x-temp
|@pen-x <- @pen-x-temp, @pen-x-temp | @pen-x, @pen-x <- @pen-x-temp
|@pen-x <- @pen-x-temp |
|@pixel-y = @pen-y, @pen-y | @pen-y-temp,
@pixel-y,
@pixel-y = @pen-y
|@pixel-y = @pen-y | @pen-y <- @pen-y-temp
|@pen-y <- @pen-y-temp, @pen-y-temp | @pen-y, @pen-y <- @pen-y-temp
|@pen-y <- @pen-y-temp |
|@trigger-set-pixel| @pixel-r += 255, @pixel-g += 255, @pixel-b += 255, set pixel
|set pixel| @set-pixel
|@pen-x++| @pen-x
|@pen-x--, @pen-x|
|@pen-x--|
|@pen-y++| @pen-y
|@pen-y--, @pen-y|
|@pen-y--|
|@pen-left, @pen-draw|
@pixel-x = @pen-x:max,
@pixel-y = @pen-y:max,
@pen-draw,
@trigger-set-pixel,
@pen-x--
|@pen-left|
@pen-x--
|@pen-right, @pen-draw|
@pixel-x = @pen-x:max,
@pixel-y = @pen-y:max,
@pen-draw,
@trigger-set-pixel,
@pen-x++
|@pen-right|
@pen-x++
|@pen-up, @pen-draw|
@pixel-x = @pen-x:max,
@pixel-y = @pen-y:max,
@pen-draw,
@trigger-set-pixel,
@pen-y--
|@pen-up|
@pen-y--
|@pen-down, @pen-draw|
@pixel-x = @pen-x:max,
@pixel-y = @pen-y:max,
@pen-draw,
@trigger-set-pixel,
@pen-y++
|@pen-down|
@pen-y++
|| start
|start|
set up the screen,
pen up,
rrrr,rrrr,rrrr,rrrr,
dddd,dddd,dddd,dddd,
main
|set up the screen|
@resolution-x += 255,
@resolution-x += 255,
@resolution-y += 255,
@resolution-y += 255,
set the screen resolution
|set the screen resolution| @set-resolution
|main|
poll for input,
clear the screen,
draw a frame,
display,
loop
|poll for input| @poll-input
|clear the screen| @clear-screen
|draw a frame|1
|1|2, pen down, rrrr, rrrr, rrrr, rrrr
|2|3, dddd, dddd, dddd, dddd
|3|4, llll, llll, llll, llll
|4|5, uuuu, uuuu, uuuu, uuuu
|5| , pen up, r, d
|display| @display
|loop, @quit|
|loop| main
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 | |@pixel-x = @pen-x:max| @pixel-x = @pen-x:4294967295 |
63 | |@pixel-y = @pen-y:max| @pixel-y = @pen-y:4294967295 |
64 | |@pen-x <- @pen-x-temp:max| @pen-x <- @pen-x-temp:4294967295 |
65 | |@pen-y <- @pen-y-temp:max| @pen-y <- @pen-y-temp:4294967295 |
66 | |
67 | |@pixel-x = @pen-x, @pen-x | @pen-x-temp, |
68 | @pixel-x, |
69 | @pixel-x = @pen-x |
70 | |@pixel-x = @pen-x | @pen-x <- @pen-x-temp |
71 | |@pen-x <- @pen-x-temp, @pen-x-temp | @pen-x, @pen-x <- @pen-x-temp |
72 | |@pen-x <- @pen-x-temp | |
73 | |
74 | |@pixel-y = @pen-y, @pen-y | @pen-y-temp, |
75 | @pixel-y, |
76 | @pixel-y = @pen-y |
77 | |@pixel-y = @pen-y | @pen-y <- @pen-y-temp |
78 | |@pen-y <- @pen-y-temp, @pen-y-temp | @pen-y, @pen-y <- @pen-y-temp |
79 | |@pen-y <- @pen-y-temp | |
80 | |
81 | |@trigger-set-pixel| @pixel-r += 255, @pixel-g += 255, @pixel-b += 255, set pixel |
82 | |set pixel| @set-pixel |
83 | |
84 | |@pen-x++| @pen-x |
85 | |@pen-x--, @pen-x| |
86 | |@pen-x--| |
87 | |
88 | |@pen-y++| @pen-y |
89 | |@pen-y--, @pen-y| |
90 | |@pen-y--| |
91 | |
92 | |@pen-left, @pen-draw| |
93 | @pixel-x = @pen-x:max, |
94 | @pixel-y = @pen-y:max, |
95 | @pen-draw, |
96 | @trigger-set-pixel, |
97 | @pen-x-- |
98 | |
99 | |@pen-left| |
100 | @pen-x-- |
101 | |
102 | |@pen-right, @pen-draw| |
103 | @pixel-x = @pen-x:max, |
104 | @pixel-y = @pen-y:max, |
105 | @pen-draw, |
106 | @trigger-set-pixel, |
107 | @pen-x++ |
108 | |
109 | |@pen-right| |
110 | @pen-x++ |
111 | |
112 | |@pen-up, @pen-draw| |
113 | @pixel-x = @pen-x:max, |
114 | @pixel-y = @pen-y:max, |
115 | @pen-draw, |
116 | @trigger-set-pixel, |
117 | @pen-y-- |
118 | |
119 | |@pen-up| |
120 | @pen-y-- |
121 | |
122 | |@pen-down, @pen-draw| |
123 | @pixel-x = @pen-x:max, |
124 | @pixel-y = @pen-y:max, |
125 | @pen-draw, |
126 | @trigger-set-pixel, |
127 | @pen-y++ |
128 | |
129 | |@pen-down| |
130 | @pen-y++ |
131 | |
132 | |
133 | |
134 | |
135 | || start |
136 | |start| |
137 | set up the screen, |
138 | pen up, |
139 | rrrr,rrrr,rrrr,rrrr, |
140 | dddd,dddd,dddd,dddd, |
141 | main |
142 | |set up the screen| |
143 | @resolution-x += 255, |
144 | @resolution-x += 255, |
145 | @resolution-y += 255, |
146 | @resolution-y += 255, |
147 | set the screen resolution |
148 | |set the screen resolution| @set-resolution |
149 | |main| |
150 | poll for input, |
151 | clear the screen, |
152 | draw a frame, |
153 | display, |
154 | loop |
155 | |poll for input| @poll-input |
156 | |clear the screen| @clear-screen |
157 | |draw a frame|1 |
158 | |1|2, pen down, rrrr, rrrr, rrrr, rrrr |
159 | |2|3, dddd, dddd, dddd, dddd |
160 | |3|4, llll, llll, llll, llll |
161 | |4|5, uuuu, uuuu, uuuu, uuuu |
162 | |5| , pen up, r, d |
163 | |display| @display |
164 | |loop, @quit| |
165 | |loop| main |
166 |