a way to draw fat lines in a program(only a class)
Author |
Message |
kit-kat-kid
![](http://www.nestle.no/site_dir/nestle_no/images/kit-kat-chunky-web33.jpg)
|
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
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
kit-kat-kid
![](http://www.nestle.no/site_dir/nestle_no/images/kit-kat-chunky-web33.jpg)
|
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 |
|
|
|
|
![](images/spacer.gif) |
Paul
![](http://i12.photobucket.com/albums/a207/paulbian/DDRDuck.png)
|
Posted: Wed May 05, 2004 6:22 pm Post subject: (No subject) |
|
|
Huh? u don't have to import anything in Draw.ThickLine. |
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
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. |
|
|
|
|
![](images/spacer.gif) |
kit-kat-kid
![](http://www.nestle.no/site_dir/nestle_no/images/kit-kat-chunky-web33.jpg)
|
Posted: Wed May 05, 2004 8:06 pm Post subject: (No subject) |
|
|
hey dosent matter as long as it works |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
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! |
|
|
|
![](images/spacer.gif) |
kit-kat-kid
![](http://www.nestle.no/site_dir/nestle_no/images/kit-kat-chunky-web33.jpg)
|
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 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
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.. |
|
|
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
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! |
|
|
|
![](images/spacer.gif) |
kit-kat-kid
![](http://www.nestle.no/site_dir/nestle_no/images/kit-kat-chunky-web33.jpg)
|
Posted: Fri May 07, 2004 12:09 pm Post subject: (No subject) |
|
|
ok cool |
|
|
|
|
![](images/spacer.gif) |
|
|