Fractal Tree
Author |
Message |
BenLi
![](http://compsci.ca/v3/uploads/user_avatars/17704181124608ffcaeb421.gif)
|
Posted: Tue Dec 12, 2006 8:57 pm Post subject: Fractal Tree |
|
|
And now, for no reason at all...fractal tree
code: |
%this creates a regular fractal tree, the angles are controlled by mouse's y position
setscreen ("graphics:max,max")
var cnt := 0
proc frac (x, y, ang, leng, n, ang2 : real)
if n > 0 then
Draw.ThickLine (round (x), round (y), round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), n div 3, 255)
frac (round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), ang + ang2, leng - 10, n - 1, ang2)
frac (round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), ang - ang2, leng - 10, n - 1, ang2)
end if
end frac
var mx, my, mb : int
setscreen ("offscreenonly")
loop
mousewhere (mx, my, mb)
frac (maxx div 2, 0, 90, 100, 7, (maxy - my) div 20)
View.Update
cls
end loop
|
this is the one that has been randomized. I think it looks decent.
code: |
setscreen ("graphics:max,max")
var cnt := 0
proc frac (x, y, ang, leng, n : real)
if n > 8 then
Draw.ThickLine (round (x), round (y), round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), n div 2, RGB.AddColor (.3, .3, 0))
else
Draw.ThickLine (round (x), round (y), round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), n div 2, RGB.AddColor (0, Rand.Real, 0))
end if
if n > 0 then
frac (round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), ang + Rand.Int (5, 15), leng - Rand.Int (1, 5), n - 1)
frac (round (((cosd (ang)) * leng) + x), round (((sind (ang)) * leng) + y), ang - Rand.Int (5, 15), leng - Rand.Int (1, 5), n - 1)
end if
end frac
frac (maxx div 2, 0, 90, 50, 16)
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Tue Dec 12, 2006 10:20 pm Post subject: (No subject) |
|
|
I like the last one, but the first runs a bit slow. What was the cnt variable for? |
|
|
|
|
![](images/spacer.gif) |
BenLi
![](http://compsci.ca/v3/uploads/user_avatars/17704181124608ffcaeb421.gif)
|
Posted: Wed Dec 13, 2006 8:43 am Post subject: (No subject) |
|
|
the cnt variable wasn't used |
|
|
|
|
![](images/spacer.gif) |
iamcow
|
Posted: Thu Dec 14, 2006 9:21 am Post subject: (No subject) |
|
|
not bad, I liked the second one. However, the brown branches look kinda bare |
|
|
|
|
![](images/spacer.gif) |
kshorting
|
Posted: Sun Aug 19, 2007 9:07 pm Post subject: Re: Fractal Tree |
|
|
BenLi,
Thank you. Fun stuff. I'll be having some fun playing with this.
Thanks,
KS |
|
|
|
|
![](images/spacer.gif) |
UraniumLobster
|
Posted: Wed Sep 12, 2007 10:11 am Post subject: RE:Fractal Tree |
|
|
Thats pretty sweet, it kept me busy for about 5 mins =P. Thats good considering its not even a game, pretty cool idea! |
|
|
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Wed Sep 12, 2007 3:43 pm Post subject: Re: RE:Fractal Tree |
|
|
UraniumLobster @ Wed Sep 12, 2007 10:11 am wrote: Thats pretty sweet, it kept me busy for about 5 mins =P. Thats good considering its not even a game, pretty cool idea!
Things don't have to be games to be cool... |
|
|
|
|
![](images/spacer.gif) |
cpu_hacker4.0
|
Posted: Fri Sep 21, 2007 7:06 pm Post subject: RE:Fractal Tree |
|
|
man how do you figure that stuff out? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Clayton
![](http://compsci.ca/v3/uploads/user_avatars/1718239683472e5c8d7e617.jpg)
|
Posted: Fri Sep 21, 2007 7:12 pm Post subject: RE:Fractal Tree |
|
|
Wikipedia is a fantastic resources for algorithms for fractals and such. |
|
|
|
|
![](images/spacer.gif) |
cpu_hacker4.0
|
Posted: Tue Oct 09, 2007 7:49 pm Post subject: Re: Fractal Tree |
|
|
Thanks, I'll be sure to check it out. |
|
|
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Tue Oct 09, 2007 7:52 pm Post subject: RE:Fractal Tree |
|
|
Also look up recursion in the Turing Walkthrough. |
|
|
|
|
![](images/spacer.gif) |
cpu_hacker4.0
|
Posted: Tue Oct 09, 2007 8:03 pm Post subject: Re: Fractal Tree |
|
|
ok thanks |
|
|
|
|
![](images/spacer.gif) |
|
|