If you know how to draw rectangle, how can you draw a triangle on it? See following picture. You already drew a square as GraphicsWindow.DrawRectangle(100, 200, 200, 200). So, the triangle you should draw has three points (x1 = 100, y1 = 200), (x2 = 300, y2 = 200), (x3 = 200, y3 = 50). There are 6 coordinate for the triangle.
So the answer is GraphicsWindow.DrawTriangle(100, 200, 300, 200, 200, 50).
gw
=
GraphicsWindow
.
Width
gh
Height
Title
"How to Draw Triangle"
DrawGrid
(
)
x
100
y
200
width
height
PenWidth
4
PenColor
"Green"
DrawRectangle
,
x1
y1
x2
300
y2
x3
y3
50
"DimGray"
DrawTriangle
DrawPoints
Sub
' param x1, y1, x2, y2, x3, y3
size
8
r
/
2
BrushColor
"Black"
FillEllipse
-
DrawText
+
"P1=("
","
")"
"P2=("
"P3=("
EndSub
"MediumSeaGreen"
For
_x
0
To
Step
DrawLine
If
<
Then
"x"
Else
EndIf
EndFor
_y
"y"
Ed Price - MSFT edited Revision 3. Comment: grammar - Great article, Nonki!
Nonki Takahashi edited Revision 2. Comment: typo
Nonki Takahashi edited Revision 1. Comment: minor change
This article is from social.msdn.microsoft.com/.../75f222c1-6f2c-4495-90de-6316c2c9a912 .