@@ -161,7 +161,7 @@ tree(115)
161161"
162162},
163163{
164- "name" : " Colors1 " ,
164+ "name" : " circles " ,
165165"src" :
166166"
167167import graphics
@@ -173,13 +173,118 @@ for i = 1 to 4 do
173173 for j = 1 to 4 do
174174 r = random.randint(255)
175175 g = random.randint(255)
176- b = random.randint(255)
176+ b = random.randint(255)
177177 graphics.pencolor (r, g, b);
178178 graphics.brushcolor (r, g, b);
179179 graphics.fillellipse (j*80,i*100,70,70)
180180 end
181181end
182182"
183+ },
184+ {
185+ "name" : " lines" ,
186+ "src" :
187+ "
188+ import graphics
189+ import math
190+ import random
191+
192+ p = graphics.size()
193+ width = p[0]; height = p[1]
194+
195+ graphics.clear()
196+ for i = 1 to 100 do
197+ graphics.penwidth (3+random.randint(4))
198+ graphics.pencolor(
199+ random.randint (255),
200+ random.randint (255),
201+ random.randint (255)
202+ )
203+ graphics.moveto(random.randint (width),random.randint (height))
204+ graphics.lineto(random.randint (width),random.randint (height))
205+ end
206+ "
207+ },
208+ {
209+ "name" : " spiral" ,
210+ "src" :
211+ "
212+ // From spiral.go
213+ import graphics
214+ import math
215+
216+ s = 520
217+ num = 600
218+
219+ graphics.clear()
220+ graphics.pencolor (255, 0, 0)
221+ graphics.brushcolor (255, 0, 0)
222+
223+ for i = 0 to num do
224+ t = i / num
225+ d = t*s*0.4 + 10
226+ a = t * math.pi * 2 * 20
227+ x = s/2 + math.cos(a)*d
228+ y = s/2 + math.sin(a)*d
229+ r = t * 8
230+ graphics.fillellipse (x, y, r, r)
231+ end"
232+ },
233+ {
234+ "name" : " mandelbrot" ,
235+ "src" :
236+ "
237+ import graphics
238+ import time
239+
240+ graphics.clear();
241+
242+ p = graphics.size()
243+ kt = 319
244+ itermax = 100; // how many iterations to do
245+ width = p[0]; // horizonal resolution
246+ height= p[1]; // vertical resolution
247+
248+ t1 = time.getTickCount()
249+ for row = 0 to height - 1 do
250+ for col = 0 to width - 1 do
251+ c_re = (col - width/2.0)*4.0/width
252+ c_im = (row - height/2.0)*4.0/width
253+ x = 0; y = 0
254+ k = 0
255+
256+ while (x*x+y*y <= 4) and (k < 319) do
257+ x_new = x*x - y*y + c_re;
258+ y = 2*x*y + c_im;
259+ x = x_new;
260+ k = k + 1
261+ end
262+
263+ if k < kt then
264+ if k < 16 then
265+ graphics.pencolor (k * 8, k * 8, 128 + k * 4)
266+ end
267+ if (k >= 16) and (k < 64) then
268+ graphics.pencolor (128 + k - 16, 128 + k - 16, 192 + k - 16)
269+ end
270+ if k >= 64 then
271+ graphics.pencolor (kt - k, 128 + (kt - k) / 2, kt - k)
272+ end
273+ graphics.pixel (row, col)
274+ else
275+ graphics.brushcolor (1,1,1)
276+ graphics.pencolor (1, 1, 1)
277+ graphics.pixel (row, col)
278+ end
279+ end
280+
281+ if row mod 50 == 0 then
282+ println (row)
283+ end
284+ end
285+ println (\"Done\");
286+ println (\"Time = \", time.getTickCount() - t1, \" ms\")
287+ "
183288}
184289 ]
185290}
0 commit comments