Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
[source] fractal tree
Author Message
zylum

Posted: Sun Mar 14, 2004 12:14 am   Post subject: [source] fractal tree

here's a simple example of a fractal tree....

 code: setscreen ("graphics:500;600") proc fractal (x, y, depth, maxDepth, angle, maxLength : int)     var endx, endy, ang : int     for i : 1 .. depth         ang := angle + Rand.Int (-15 * depth, 15 * depth)         endx := round (cosd (ang) * maxLength) + x         endy := round (sind (ang) * maxLength) + y         Draw.ThickLine (x, y, endx, endy, (maxDepth - depth + 1) * 2, 115)         %delay (10)         if depth <= maxDepth then             fractal (endx, endy, depth + 1, maxDepth, ang, round (maxLength * 0.75))         else             drawfilloval (endx, endy, 3, 3, green)         end if     end for end fractal fractal (maxx div 2, 30, 1, 5, 90, 150)

here's one with a back ground:

 code: setscreen ("graphics:500;600") proc fractal (x, y, depth, maxDepth, angle, maxLength : int)     var endx, endy, ang : int     for i : 1 .. depth         ang := angle + Rand.Int (-15 * depth, 15 * depth)         endx := round (cosd (ang) * maxLength) + x         endy := round (sind (ang) * maxLength) + y         Draw.ThickLine (x, y, endx, endy, (maxDepth - depth + 1) * 2, 115)         %delay (10)         if depth <= maxDepth then             fractal (endx, endy, depth + 1, maxDepth, ang, round (maxLength * 0.75))         else             drawfilloval (endx, endy, 3, 3, green)         end if     end for end fractal var clr : int for i : 0 .. maxy     clr := RGB.AddColor (i / (maxy + 250), i / (maxy + 250), 1)     drawline (0, maxy - i, maxx, maxy - i, clr)     %delay (10) end for for i : 0 .. 100     drawfillbox (0, i, maxx, i, green)     %delay (10) end for var x, y : int for i : 1 .. 10000     clr := RGB.AddColor (100 / Rand.Int (300, 1500), Rand.Real * 0.5 + 0.5, 100 / Rand.Int (300, 2500))     x := Rand.Int (0, maxx)     y := Rand.Int (0, 100)     drawline (x, y, x, y + Rand.Int (4, 9), clr) end for fractal (maxx div 2, 30, 1, 5, 90, 150)

-zylum

guruguru

Posted: Sun Mar 14, 2004 12:47 am   Post subject: (No subject)

Wow! Dam thats good! Even looking at ure code I can barely figure out how you did that...

+ Bits indeed
Catalyst

Posted: Sun Mar 14, 2004 12:49 am   Post subject: (No subject)

I like it
Especially the grass

Keep up the good work!

have... 45 bits
recneps

Posted: Sun Mar 14, 2004 10:48 am   Post subject: (No subject)

*absolutely no idea how that works.....* have some bits
AsianSensation

Posted: Sun Mar 14, 2004 1:13 pm   Post subject: (No subject)

+50 bits
shorthair

Posted: Sun Mar 14, 2004 2:09 pm   Post subject: (No subject)

+ 35 BITS ( you cant have to many now ,,,....... )

great program , i ca nsee you really know your math , its a rocking program ,im really impresed , keep up this excellent roll your on
zylum

Posted: Sun Mar 14, 2004 6:12 pm   Post subject: (No subject)

wow, lots of bits for that one

here's an new and improved version, it's a forest and the trees actually grow

 code: setscreen ("graphics:1000;680,nobuttonbar") const d := 5 process fractal (x, y, depth, maxDepth, angle, maxLength : int)     var endx, endy, ang : int     for i : 1 .. depth         ang := angle + Rand.Int (-15 * depth, 15 * depth)         for l : 1 .. maxLength             endx := round (cosd (ang) * l) + x             endy := round (sind (ang) * l) + y             Draw.ThickLine (x, y, endx, endy, (maxDepth - depth + 1) * 2, 115)             delay (round (((maxDepth - depth) * 5 + 10) * d))         end for         delay (round (300 * d))         if depth <= maxDepth then             fork fractal (endx, endy, depth + 1, maxDepth, ang, round (maxLength * 0.75))         else             for l : 1 .. Rand.Int (2, 5)                 drawfilloval (endx, endy, l, l, green)                 delay (round (50 * d))             end for         end if     end for end fractal var clr : int for i : 0 .. maxy     clr := RGB.AddColor (i / (maxy + 250), i / (maxy + 250), 1)     drawline (0, maxy - i, maxx, maxy - i, clr)     %delay (10) end for for i : 0 .. 100     drawfillbox (0, i, maxx, i, green)     %delay (10) end for var x, y : int for i : 1 .. 20000     clr := RGB.AddColor (100 / Rand.Int (300, 1500), Rand.Real * 0.5 + 0.5, 100 / Rand.Int (300, 2500))     x := Rand.Int (0, maxx)     y := Rand.Int (0, 100)     drawline (x, y, x, y + Rand.Int (4, 9), clr) end for for i : 1 .. Rand.Int (10, 30)     fork fractal (Rand.Int (100, maxx - 100), Rand.Int (0, 100), 1, Rand.Int (3, 4), 90, Rand.Int (50, 200))     delay (Rand.Int (100, 2000)) end for

-zylum
the_short1

Posted: Sun Mar 14, 2004 6:36 pm   Post subject: (No subject)

what grade math u in... also waht is ur mark... cuz DAM ur good... .if i was a MOD i would give you 100 BITS.. ur deserv it... cuz all this drawing deal with advanced math functions in turing... just WOW... lookz soo COOL

OMG i just loked at the forest one... i REALY dont know how u can make sh!t THAT good in only 50 lines of code... and like no time.... god... U are PRO... i think everyone shall bow down to ur greatness......

im amazed... the only program i have seen that compared to this.. is taht tree taht catalyst made... but i cant run that no more... and it didn;t grow from GRASSS... DAM...

Tony

Posted: Sun Mar 14, 2004 7:05 pm   Post subject: (No subject)

nice, all you need to do now is give different colors to the trees so that trees that are further behind are darker then those up front
Tony's programming blog. DWITE - a programming contest.
Cervantes

Posted: Sun Mar 14, 2004 7:29 pm   Post subject: (No subject)

*whistles*
slick!

+40 BITS
jonos

Posted: Sun Mar 14, 2004 11:37 pm   Post subject: (No subject)

id give bits, but im not a mod like all you other people, but its still awesome none-the-less. makes me want to know more math......
the_short1

Posted: Mon Mar 15, 2004 12:27 pm   Post subject: (No subject)

... welll jonos yu can be lkike me... and donate to get to the nearest 5 bits...like right now i have ,,.,644 BITS... so i donate 4... to get to 640...

there... Zylum... 4+ BITS... u deserve them.i think u deserve a Newbe God Status or something.... bugpodder got a leet ranking with his minor ammounts of post....u should be able to get that...np... once he gets back
AsianSensation

Posted: Mon Mar 15, 2004 7:29 pm   Post subject: (No subject)

the_short1 wrote:
bugpodder got a leet ranking with his minor ammounts of post....

bugzpodder is also one of the smartest guy you will meet. So yeah...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 13 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: