Ajoute un polygone la figure
#include <GDIPlus.au3>
_GDIPlus_PathAddPolygon ( $hPath, $aPoints )
$hPath | Handle de l'objet GraphicsPath |
$aPoints | Tableau de points qui définit les sommets du polygone: [0][0] - Nombre de points [1][0] - Point 1, position X [1][1] - Point 1, position Y [2][0] - Point 2, position X [2][1] - Point 2, position Y [n][0] - Point n, position X [n][1] - Point n, position Y |
Succès: | Retourne True. |
Échec: | Retourne False et définit @error <> 0, @extended contient le code erreur ($GPID_ERR*). |
Consultez GdipAddPathPolygon dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath ; Crée une GUI $hGUI = GUICreate("GDI+", 800, 300) GUISetState(@SW_SHOW) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet graphique à partir du handle de la fenêtre _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) $hBrush = _GDIPlus_BrushCreateSolid(0x7F8800AA) $hPen = _GDIPlus_PenCreate(0xFF8800AA, 2) $hPen2 = _GDIPlus_PenCreate(0xFFFF0000, 2) Local $aPoints[5][2] = [[4]] $aPoints[1][0] = 10 $aPoints[1][1] = 70 $aPoints[2][0] = 60 $aPoints[2][1] = 50 $aPoints[3][0] = 110 $aPoints[3][1] = 120 $aPoints[4][0] = 160 $aPoints[4][1] = 80 $hPath = _GDIPlus_PathCreate() ; Crée un objet path _GDIPlus_GraphicsDrawString($hGraphic, "Curve", $aPoints[1][0], 20) _GDIPlus_PathAddCurve($hPath, $aPoints) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] += 200 Next _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve", $aPoints[1][0], 20) _GDIPlus_PathAddClosedCurve($hPath, $aPoints) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] += 200 Next _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0.8", $aPoints[1][0], 20) _GDIPlus_PathAddCurve2($hPath, $aPoints, 0.8) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] += 200 Next _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0.8", $aPoints[1][0], 20) _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0.8) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] -= 500 $aPoints[$i][1] += 140 Next _GDIPlus_GraphicsDrawString($hGraphic, "Curve2 tension = 0", $aPoints[1][0], 160) _GDIPlus_PathAddCurve2($hPath, $aPoints, 0) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] += 200 Next _GDIPlus_GraphicsDrawString($hGraphic, "ClosedCurve2 tension = 0", $aPoints[1][0], 160) _GDIPlus_PathAddClosedCurve2($hPath, $aPoints, 0) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) $aPoints[$i][0] += 200 Next _GDIPlus_GraphicsDrawString($hGraphic, "Polygon", $aPoints[1][0], 160) _GDIPlus_PathAddPolygon($hPath, $aPoints) For $i = 1 To $aPoints[0][0] _GDIPlus_GraphicsDrawRect($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2) Next _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Dessine le Path avec le handle Graphic (GUI) _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Dessine le Path avec le handle Graphic (GUI) ; Boucle jusqu'à ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources _GDIPlus_PathDispose($hPath) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_PenDispose($hPen2) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example