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

Username:   Password: 
 RegisterRegister   
 Tree
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Catalyst




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

I was bored in compsci (whole class learning put/get Laughing ) the other day
so i made this

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)
Sponsor
Sponsor
Sponsor
sponsor
poly




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

thats pretty sweet!
JSBN




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

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




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




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


Laughing

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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
PaddyLong




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




PostPosted: 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 Evil or Very Mad
rizzix




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

whats Draw.ThickLine ? never seen that before.
Catalyst




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




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Catalyst




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




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




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

Home finaly! Thats sweet.
LJ




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

That's sick!
the_short1




PostPosted: 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:   
   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 2  [ 23 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: