Si vous savez dessiner un rectangle, comment pouvez-vous dessiner un triangle ?
Regardez l'image suivante. Vous avez déjà dessiné un carré avec GraphicsWindow.DrawRectangle(100, 200, 200, 200).  Donc, le triangle que vous devez dessiner à trois points (x1 = 100, y1 = 200), (x2 = 300, y2 = 200), (x3 = 200, y3 = 50).  Il y a 6 coordonnées pour le triangle.

Par conséquent la réponse est GraphicsWindow.DrawTriangle(100, 200, 300, 200, 200, 50).

Le code qui suit dessine l'image précédente.

`gw ````= ````GraphicsWindow``.``Width`
`gh ````= ````GraphicsWindow``.``Height`
`GraphicsWindow``.````Title ````= ``"How to Draw Triangle"`
`DrawGrid``(``)`
`x ````= ````100`
`y ````= ````200`
`width ````= ````200`
`height ````= ````200`
`GraphicsWindow``.````PenWidth ````= ``4`
`GraphicsWindow``.````PenColor ````= ``"Green"`
`GraphicsWindow``.``DrawRectangle``(``x````, ````y``, ``width````, ````height``)`
`x1 ````= ````100`
`y1 ````= ````200`
`x2 ````= ````300`
`y2 ````= ````200`
`x3 ````= ````200`
`y3 ````= ````50`
`GraphicsWindow``.````PenColor ````= ``"DimGray"`
`GraphicsWindow``.``DrawTriangle``(``x1````, ````y1``, ` `x2``, ``y2````, ````x3``, ` `y3``)`
`DrawPoints``(``)`
```Sub ````DrawPoints`
`  ``' param x1, y1, x2, y2, x3, y3`
`  ````size ````= ``8`
`  ````r ````= ``size ` `/ ``2`
`  ``GraphicsWindow``.````BrushColor ````= ``"Black"`
`  ``GraphicsWindow``.``FillEllipse``(````x1 ````- ``r````, ````y1 ``- ` `r``, ``size````, ````size``)`
`  ``GraphicsWindow``.``DrawText``(````x1 ````+ ``4````, ````y1 ``+ ` `4``, ````"P1=(" ````+ ``x1 ` `+ ``"," ````+ ````y1 ``+ ` `")"``)`
`  ``GraphicsWindow``.``FillEllipse``(````x2 ````- ``r````, ````y2 ``- ` `r``, ``size````, ````size``)`
`  ``GraphicsWindow``.``DrawText``(````x2 ````+ ``4````, ````y2 ``+ ` `4``, ````"P2=(" ````+ ``x2 ` `+ ``"," ````+ ````y2 ``+ ` `")"``)`
`  ``GraphicsWindow``.``FillEllipse``(````x3 ````- ``r````, ````y3 ``- ` `r``, ``size````, ````size``)`
`  ``GraphicsWindow``.``DrawText``(````x3 ````+ ``4````, ````y3 ``+ ` `4``, ````"P3=(" ````+ ``x3 ` `+ ``"," ````+ ````y3 ``+ ` `")"``)`
`EndSub`
```Sub ````DrawGrid`
`  ``GraphicsWindow``.````PenColor ````= ``"MediumSeaGreen"`
`  ``GraphicsWindow``.````BrushColor ````= ``"MediumSeaGreen"`
`  ````For ````_x ``= ` `0 ````To ````gw ````Step ````50`
`    ``GraphicsWindow``.``DrawLine``(``_x````, ````0``, ``_x````, ````gh``)`
`    ````If ````gw ``- ` `50 ``< ````_x ````Then`
`      ``GraphicsWindow``.``DrawText``(````_x ````+ ``4````, ````4``, ``"x"``)`
`    ``Else`
`      ``GraphicsWindow``.``DrawText``(````_x ````+ ``4````, ````4``, ``_x``)`
`    ``EndIf`
`  ``EndFor`
`  ````For ````_y ``= ` `0 ````To ````gh ````Step ````50`
`    ``GraphicsWindow``.``DrawLine``(``0````, ````_y``, ` `gw``, ``_y``)`
`    ````If ````gh ``- ` `50 ``< ````_y ````Then`
`      ``GraphicsWindow``.``DrawText``(``4````, ````_y ``+ ` `4``, ``"y"``)`
`    ``Else`
`      ``GraphicsWindow``.``DrawText``(``4````, ````_y ``+ ` `4``, ``_y``)`
`    ``EndIf`
`  ``EndFor`
`EndSub`

Vous pouvez également voir un autre exemple avec GraphicsWindow.FillTriangle()  ici