Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Tree
Author Message
Catalyst

Posted: Sun Oct 05, 2003 1:48 am   Post subject: Tree

I was bored in compsci (whole class learning put/get ) the other day

 code: % Tree proc AddGradient (c1, c2, n : int)     var clr : int     var r1, g1, b1, r2, g2, b2, p, p0 : real     RGB.GetColor (c1, r1, g1, b1)     RGB.GetColor (c2, r2, g2, b2)     const a := 50     for i : 1 .. n         p := (i / n) * 100         p0 := 100 - p         clr := RGB.AddColor ((((r1 * p) + (r2 * p0)) / 2) / a, (((g1 * p) + (g2 * p0)) / 2) / a, (((b1 * p) + (b2 * p0)) / 2) / a)     end for end AddGradient AddGradient (114, 114, 220) AddGradient (2, 10, 35) type Point :     record         x, y : real     end record var holdPoint : Point holdPoint.x := 0 holdPoint.y := 0 fcn RandReal : real     result (Rand.Real * 2 - 1) * 10 end RandReal fcn AngleFrom (X, Y : real, dist, ang : real) : Point     holdPoint.x := (cosd (ang) * dist) + X     holdPoint.y := (sind (ang) * dist) + Y     result holdPoint end AngleFrom var md : int := 150 var inc : real := 45 var reduc : real := 2 var numB : int := 3 proc MakeTree (X, Y : real, ang : real, dist : real)     var test := AngleFrom (X, Y, dist, ang)     if 511 - round (255 * dist / md) + 1 <= 511 - 36 then         Draw.ThickLine (round (X), round (Y), round (test.x), round (test.y), round (dist / md * 25), 511 - round (255 * dist / md) + 1)     else         Draw.ThickLine (round (X), round (Y), round (test.x), round (test.y), round (dist / md * 10), 511 - round (255 * dist / md) + 1)     end if     if dist <= 10 then         return     end if     for i : 0 .. numB         MakeTree (test.x, test.y, RandReal + ang + (inc * ((i / numB) * 2 - 1)), dist / reduc + (dist / reduc * Rand.Real * Rand.Real))     end for end MakeTree MakeTree (maxx div 2, 0, 90 + Rand.Int (-15, 15), md)

poly

Posted: Sun Oct 05, 2003 12:31 pm   Post subject: (No subject)

thats pretty sweet!
JSBN

Posted: Sun Oct 05, 2003 12:39 pm   Post subject: (No subject)

damn. that's pretty sweet. wish i could do that.

Posted: Sun Oct 05, 2003 1:27 pm   Post subject: (No subject)

heh cool... what did your teacher and classmates think of that? or were they too busy making cheasy little put/get programs? 8)
Tony

Posted: Sun Oct 05, 2003 1:35 pm   Post subject: (No subject)

 code: var answer:string put "would you like to draw a tree?" get answer put "I don't yet know how to use IF statments" put "so I'll just assume you said yes" put "I don't yet know how to use graphics in turing" put "so just open M\$ Paint and draw a tree there"

Heh. Catalyst - Bring a pillow to class and/or install some C++ compiler & IDE. Just cuz you ended up in a class full of kids who got trouble using put/get, doesn't mean you have to waste your time.
Tony's programming blog. DWITE - a programming contest.

Posted: Sun Oct 05, 2003 1:37 pm   Post subject: (No subject)

does your teacher actually like teach stuff in your compsci class? mine just put some tutorials he wrote into a directory and we would just do those at our own pace with assignments from each chapter along the way.
Catalyst

Posted: Sun Oct 05, 2003 6:03 pm   Post subject: (No subject)

my teacher likes to have a powerpoint projector running as he explains the programs(if u could call them that)
tony- ive got devc++ on my account but network restrictions wont let me compie
rizzix

Posted: Sun Oct 05, 2003 6:25 pm   Post subject: (No subject)

whats Draw.ThickLine ? never seen that before.

Catalyst

Posted: Sun Oct 05, 2003 6:42 pm   Post subject: (No subject)

its one of the newer functions from 4.0
it draws a thick line
the syntax is the same is drawline but there is a thickness parameter b4 the color
Tony

Posted: Sun Oct 05, 2003 6:56 pm   Post subject: (No subject)

I wouldn't be surpriced if that Draw.ThickLine is just a Draw.FillPolygon with points calculated from passed values.

Turing is soo cheap - a bunch of build in functions are writen in turing itself and slow the program down.
Tony's programming blog. DWITE - a programming contest.
Catalyst

Posted: Sun Oct 05, 2003 10:15 pm   Post subject: (No subject)

i think the draw functions are actually just mapped from the windows gdi functions, but i might be wrong
hackman

Posted: Thu Oct 09, 2003 9:57 am   Post subject: (No subject)

wish i could see that now. Im in class and my ghetto school has like v0.01, well actualy 3.1. Looks like im gona have to wait another 3 classes till i get home.
hackman

Posted: Thu Oct 09, 2003 3:13 pm   Post subject: (No subject)

Home finaly! Thats sweet.
LJ

Posted: Sat Mar 06, 2004 9:06 pm   Post subject: (No subject)

That's sick!
the_short1

Posted: Sat Mar 06, 2004 10:16 pm   Post subject: (No subject)

ummmm LJ.... when a topic is like over 1 year old.... w/e.... anyways... some kid in my compsci class had this going and he said he got it on compsci.... sweet.... now i know its the infamous Catalyst

its REALY cool if you add a loop to the Draw tree function....and it randomizes the location each time... i made a reedit but its at school...
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 2  [ 23 Posts ]
Goto page 1, 2  Next
 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: