Funktionreferenz


_GDIPlus_GraphicsDrawPolygon

Beschreibung anzeigen in

Zeichnet ein Polygon

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

Parameter

$hGraphics Handle zu einem Grafik-Objekt
$aPoints Array welches die Eckpunkte des Polygons festlegt:
    [0][0] - Anzahl von Eckpunkten
    [1][0] - Eckpunkt 1 X-Position
    [1][1] - Eckpunkt 1 Y-Position
    [2][0] - Eckpunkt 2 X-Position
    [2][1] - Eckpunkt 2 Y-Position
    [n][0] - Eckpunkt n X-Position
    [n][1] - Eckpunkt n Y-Position
$hPen [optional] Handle zu einem Zeichenstift-Objekt, welcher verwendet wird um das Polygon zu zeichnen. Falls 0 wird ein vollfarbig schwarz gefüllter Zeichenstift mit der Breite von 1 verwendet.

Rückgabewert

Erfolg: True
Fehler: False und setzt das @error Flag auf ungleich null, das @extended Flag kann den GPSTATUS-Fehlercode ($GPID_ERR* siehe GDIPlusConstants.au3) enthalten.

Bemerkungen

Falls der erste und letzte Punkt nicht identisch sind, wird eine Linie zwischen diese beiden Punkte gezeichnet um das Polygon zu schließen

Siehe auch

Suche nach GdipDrawPolygon in der MSDN Bibliothek.

Beispiel

Beispiel 1

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

Example()

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

    ; Erstellt eine GUI
    $hGui = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Zeichnet ein Polygon
    _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)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Ressourcen freigeben
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Beispiel 2

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

Example()

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

    Local $hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iWidth, $iHeight) ;create a test GUI
    GUISetBkColor($iBgColor, $hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    Local $hPen = _GDIPlus_PenCreate(0xFFFFFFFF, 40) ;color format 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) ;draw the triangle

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example