
-----------------------------------
BenLi
Tue Dec 12, 2006 8:57 pm

Fractal Tree
-----------------------------------
And now, for no reason at all...fractal tree


%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.

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)


-----------------------------------
ericfourfour
Tue Dec 12, 2006 10:20 pm


-----------------------------------
I like the last one, but the first runs a bit slow. What was the cnt variable for?

-----------------------------------
BenLi
Wed Dec 13, 2006 8:43 am


-----------------------------------
the cnt variable wasn't used

-----------------------------------
iamcow
Thu Dec 14, 2006 9:21 am


-----------------------------------
not bad, I liked the second one. However, the brown branches look kinda bare

-----------------------------------
kshorting
Sun Aug 19, 2007 9:07 pm

Re: Fractal Tree
-----------------------------------
BenLi,

Thank you. Fun stuff. I'll be having some fun playing with this.  :P 

Thanks,

 KS

-----------------------------------
UraniumLobster
Wed Sep 12, 2007 10:11 am

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!

-----------------------------------
Clayton
Wed Sep 12, 2007 3:43 pm

Re: 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!

Things don't have to be games to be cool...

-----------------------------------
cpu_hacker4.0
Fri Sep 21, 2007 7:06 pm

RE:Fractal Tree
-----------------------------------
man how do you figure that stuff out?

-----------------------------------
Clayton
Fri Sep 21, 2007 7:12 pm

RE:Fractal Tree
-----------------------------------
[url=http://wikipedia.org]Wikipedia is a fantastic resources for algorithms for fractals and such.

-----------------------------------
cpu_hacker4.0
Tue Oct 09, 2007 7:49 pm

Re: Fractal Tree
-----------------------------------
Thanks, I'll be sure to check it out.

-----------------------------------
CodeMonkey2000
Tue Oct 09, 2007 7:52 pm

RE:Fractal Tree
-----------------------------------
Also look up recursion in the turing walkthrough.

-----------------------------------
cpu_hacker4.0
Tue Oct 09, 2007 8:03 pm

Re: Fractal Tree
-----------------------------------
ok thanks
