Difference between revisions of "Digimon"
From CodeStuff
(Created page with " <code><pre> 100 →func sample, coast creation: 110 float s 120 while s<1 or s>2 130 input "ratio 1 to 2"; s 140 endwhile 150 s = (s-1)/10+1 160 screen 1...") |
|||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
| + | Code from an episode of Digimon. | ||
| + | |||
| + | http://i.imgur.com/gh3dK.jpg | ||
| + | |||
| + | http://thegenuisishere.multiply.com/journal/item/48?&show_interstitial=1&u=%2Fjournal%2Fitem | ||
<code><pre> | <code><pre> | ||
| Line 29: | Line 34: | ||
<edcode> | <edcode> | ||
| + | |||
var s = Math.random()+1; | var s = Math.random()+1; | ||
s = (s-1)/10+1; | s = (s-1)/10+1; | ||
| − | |||
s=Math.sqrt(s*s-1); | s=Math.sqrt(s*s-1); | ||
| Line 58: | Line 63: | ||
fractal(x2,x1,y2,y1,sp); | fractal(x2,x1,y2,y1,sp); | ||
} | } | ||
| + | |||
| + | |||
| + | //program done, The bit below just redraws with different seeds | ||
| + | |||
| + | function move() { | ||
| + | } | ||
| + | |||
| + | function draw() { | ||
| + | |||
| + | s=Math.random()+1; | ||
| + | clear(); | ||
| + | print(s,20,20); | ||
| + | s = (s-1)/10+1; | ||
| + | s=Math.sqrt(s*s-1); | ||
| + | fractal(100,412,0,0,1); | ||
| + | drawLine(100,50,412,50); | ||
| + | } | ||
| + | |||
| + | run(move,draw,5); | ||
| + | |||
</edcode> | </edcode> | ||
Latest revision as of 20:47, 3 February 2013
Code from an episode of Digimon.
http://thegenuisishere.multiply.com/journal/item/48?&show_interstitial=1&u=%2Fjournal%2Fitem
100 /* func sample, coast creation */
110 float s
120 while s<1 or s>2
130 input "ratio 1 to 2"; s
140 endwhile
150 s = (s-1)/10+1
160 screen 1,2,1,1
170 s=sqr(s*s-1)
180 float x0=100, x1=412, y0=0, y1=0
190 fractal(x0,x1,y0,y1,1)
200 line(100, 50, 412, 50, 255, 65535)
210 end
220 func fractal(x0;float,x1;float,y0;float,y1;float,sp;int)
230 float l, r, x2, y2
240 l=sqr[(x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)]
250 if l<2 or sp>=9 then (
260 line(x0,y0/3+50,x1,y1/3+50,255,65535) ; return()
270 )
280 r=rnd()+rnd()+rnd()-2
290 x2=(x0+x1)/2+s*(y1-y0)*r
300 y2=(y0+y1)/2+s(x0+x1)*r
310 sp = sp + 1
320 fractal(x0,x2,y0,y2,sp)
330 fractal(x2,x1,y2,y1,sp)
340 endfunc