UDF > GDIPlus > Graphics >


_GDIPlus_GraphicsDrawPolygon

Dessine un polygone

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawPolygon ( $hGraphics, $aPoints [, $hPen = 0] )

Paramètres

$hGraphics Handle de l'objet Graphics
$aPoints Tableau qui précise les sommets du polygone :
    [0][0] - Nombre de sommets
    [1][0] - Sommet 1: abscisse X
    [1][1] - Sommet 1: ordonnée Y
    [2][0] - Sommet 2: abscisse X
    [2][1] - Sommet 2: ordonnée Y
    [n][0] - Sommet n: abscisse X
    [n][1] - Sommet n: ordonnée Y
$hPen [optionnel] Handle de l'objet Pen qui est utilisé pour dessiner le polygone. Si 0, un crayon noir qui trace des traits continus de largeur de 1 sera utilisé.

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Remarque

Si les premier et dernier points ne sont pas identiques, une ligne est tracée entre eux pour fermer le polygone.

Voir aussi

Consultez GdipDrawPolygon dans la Librairie MSDN.

Exemples

Exemple 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $aPoints[4][2]

    ; Crée une GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Dessine un polygone
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

    $aPoints[0][0] = 3
    $aPoints[1][0] = 150
    $aPoints[1][1] = 150
    $aPoints[2][0] = 200
    $aPoints[2][1] = 100
    $aPoints[3][0] = 250
    $aPoints[3][1] = 150

    _GDIPlus_GraphicsDrawPolygon($hGraphic, $aPoints)

    ; Boucle jusqu'à ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example


Exemple 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    _GDIPlus_Startup() ; Initialise GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBGColor est au format RRGGBB

    Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une fenêtre de test
    GUISetBkColor($iBgColor, $hGUI) ; Définit la couleur de fond de la GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet Graphics à partir du handle de la fenêtre
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 40) ; Format de couleur AARRGGBB (hex)

    ; 1 _____ 3
    ;  \    /
    ;   \  /
    ;     2
    Local $aPoints[4][2]
    $aPoints[0][0] = 3
    $aPoints[1][0] = 50.0
    $aPoints[1][1] = 150.0
    $aPoints[2][0] = 300.0
    $aPoints[2][1] = 500.0
    $aPoints[3][0] = 550.0
    $aPoints[3][1] = 150.0

    _GDIPlus_GraphicsDrawPolygon($hGraphics, $aPoints, $hPen) ; Dessine le triangle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources GDI+
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example