Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Fractal Tree
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
BenLi




PostPosted: 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)
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: 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?
BenLi




PostPosted: Wed Dec 13, 2006 8:43 am   Post subject: (No subject)

the cnt variable wasn't used
iamcow




PostPosted: 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
kshorting




PostPosted: 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. Razz

Thanks,

KS
UraniumLobster




PostPosted: 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!
Clayton




PostPosted: 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...
cpu_hacker4.0




PostPosted: Fri Sep 21, 2007 7:06 pm   Post subject: RE:Fractal Tree

man how do you figure that stuff out?
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Fri Sep 21, 2007 7:12 pm   Post subject: RE:Fractal Tree

Wikipedia is a fantastic resources for algorithms for fractals and such.
cpu_hacker4.0




PostPosted: Tue Oct 09, 2007 7:49 pm   Post subject: Re: Fractal Tree

Thanks, I'll be sure to check it out.
CodeMonkey2000




PostPosted: Tue Oct 09, 2007 7:52 pm   Post subject: RE:Fractal Tree

Also look up recursion in the Turing Walkthrough.
cpu_hacker4.0




PostPosted: Tue Oct 09, 2007 8:03 pm   Post subject: Re: Fractal Tree

ok thanks
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: