|
02-20-2007 01:54
Posted by:
Hendo
Location:
Barrie, Ontario

|
i tried this but it created a scalene triangle:(
procedure eq (int x, int y, int size, int col)
int x2, y2, x3, y3, height
height= InvTan (height/(size/2))
x2 = x+size
y2=y
x3=(x+size)/2
y3=x3+height
set pen colour col
Line x, y To x2, y2
set pen colour col
Line x, y To x3, y3
set pen colour col
Line x2, y2 To x3, y3
end proc
while not Mouse Button
set pen colour white
paint canvas
eq(100, 200, 50, red)
draw frame
wend
what am i doing wrong?
|
|
02-20-2007 20:28
Posted by:
Hendo
Location:
Barrie, Ontario

|
ahh, i got it to work. Now here is a question. Is there anyway to fill the triangle i have created even though it is actually composed of 3 lines?
Well anyway here is the code to create an equilateral triangle of any size:
graphics mode 640,480 ' switch to graphics mode
procedure eq (int x, int y, int size, int col)
int x2, y2, x3, y3
x2=x+size
x3=x+(size/2)
y2=y
y3= Round(Sqrt (size^2-(size/2)^2) + y)
set pen colour col
Line x, y To x2, y2
set pen colour col
Line x, y To x3, y3
set pen colour col
Line x2, y2 To x3, y3
end proc
while not Mouse Button
set pen colour black
paint canvas
eq(100, 200, 200, green)
draw frame
wend
|
|
02-20-2007 21:20
Posted by:
Jacob
Location:
Michigan, USA

|
To fill your triangle just put your lines into a fill poly:
fill poly x1, y1 to x2, y2 to x3, y3
|
|
02-20-2007 21:24
Posted by:
Hendo
Location:
Barrie, Ontario

|
good call, correct you are.
Thanks!:D
|