Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
a way to draw fat lines in a program(only a class)
Author Message
kit-kat-kid

Posted: Wed May 05, 2004 7:47 am   Post subject: a way to draw fat lines in a program(only a class)

 code: %File "turtlefat.tu" %A class for creating a turtle that can draw %with different widths of lines unit class TurtleFatCl     inherit TurtleCl in "turtlecl.tu"     export SetWidth     proc ball (xc, yc, radius, clr : int)         Draw.FillOval (xc, yc, radius,radius,  clr)     end ball     var width : int := 1     proc SetWidth (newWidth : int)         width := newWidth     end SetWidth     proc drawFatLine (x1, y1, x2, y2, clr, width : int)         const len : real := sqrt ( (x2 - x1) ** 2 + (y2 - y1) ** 2)         const sinTheta : real := (y2 - y1) / len         const cosTheta : real := (x2 - x1) / len         const radius := width div 2 + 1         const dx : real := radius * cosTheta / 2         const dy : real := radius * sinTheta / 2         var xpos : real := x1         var ypos : real := y1         loop             ball (round (xpos), round (ypos), radius, clr)             xpos += dx             ypos += dy             exit when sqrt ( (x2 - xpos) ** 2 + (y2 - ypos) ** 2) < (radius                 / 2)         end loop     end drawFatLine     body procedure Move (distance : int)         const newx := round (x + cosd (angle) * distance)         const newy := round (y + sind (angle) * distance)         if showing then             if width = 1 then                 Draw.Line (x, y, newx, newy, clr)             else                 drawFatLine (x, y, newx, newy, clr, width)             end if         end if         x := newx         y := newy     end Move end TurtleFatCl

Tony

Posted: Wed May 05, 2004 2:56 pm   Post subject: (No subject)

you know, there's already Draw.ThickLine() available
Tony's programming blog. DWITE - a programming contest.
kit-kat-kid

Posted: Wed May 05, 2004 5:34 pm   Post subject: (No subject)

i know that already but this way you only have to import it
Paul

Posted: Wed May 05, 2004 6:22 pm   Post subject: (No subject)

Huh? u don't have to import anything in Draw.ThickLine.
Delos

Posted: Wed May 05, 2004 8:02 pm   Post subject: (No subject)

What they're saying is that you won't have to type
"Draw.ThickLine()"
just
"..."
where '...' represents the name of their class...in other words, just saves you a few characters of code.

That and it shows off that they know how to make something like that.

Pretty pointless otherwise.
kit-kat-kid

Posted: Wed May 05, 2004 8:06 pm   Post subject: (No subject)

hey dosent matter as long as it works
Dan

Posted: Thu May 06, 2004 4:17 pm   Post subject: (No subject)

kit-kat-kid wrote:
hey dosent matter as long as it works

Aucaly it dose, using your method whould eat up more memory then using the turing way b/c it has to read and load that class in to the ram and then exuite it rather then just the turing ones that it will be loading in to the memory any how.

Also alougth it dose shorten the line by 4-5 letters, you have to add the import line at the top of your file and include your file with it for it will not work.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
kit-kat-kid

Posted: Thu May 06, 2004 6:56 pm   Post subject: (No subject)

it also depends on how many lines you wanna make. with your way you have to do alot more work. with mine you just have to import the class

the_short1

Posted: Thu May 06, 2004 7:41 pm   Post subject: (No subject)

i dont get what u mean..
with ur way u only have to import the class..??

what...
u import the clas... then
u still have to do turtlethickline or w/e u draw it...
so.. its the same amout really..

cool... and u can make it yourself.....but not really useful..

hers 5 bits for the time it took u..
Dan

Posted: Thu May 06, 2004 8:25 pm   Post subject: (No subject)

kit-kat-kid wrote:
it also depends on how many lines you wanna make. with your way you have to do alot more work. with mine you just have to import the class

short1 is right, it is no more lines. Aucaly if u look at it at the compiler level your way is more lines b/c it has to read the class file.

Any how it is good that u figgered out how to do it on your own, it is all ways nice to know how things work (or could work).
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
kit-kat-kid

Posted: Fri May 07, 2004 12:09 pm   Post subject: (No subject)

ok cool
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 11 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: