Function Reference


_GDIPlus_GraphicsFillPolygon

Fill a polygon

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

Parameters

$hGraphics Handle to a Graphics object
$aPoints Array that specify the vertices of the polygon:
    [0][0] - Number of vertices
    [1][0] - Vertex 1 X position
    [1][1] - Vertex 1 Y position
    [2][0] - Vertex 2 X position
    [2][1] - Vertex 2 Y position
    [n][0] - Vertex n X position
    [n][1] - Vertex n Y position
$hBrush [optional] Handle to a brush object that is used to fill the polygon.

Return Value

Success: True.
Failure: False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3).

See Also

Search GdipFillPolygon in MSDN Library.

Example

Example 1

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

Example()

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

        ; Create GUI
        $hGUI = GUICreate("GDI+", 400, 300)
        GUISetState(@SW_SHOW)

        ; Draw a 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

        MsgBox($MB_SYSTEMMODAL, "Information", "Fill Polygon")

        _GDIPlus_GraphicsFillPolygon($hGraphic, $aPoints)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

        ; Clean up resources
        _GDIPlus_GraphicsDispose($hGraphic)
        _GDIPlus_Shutdown()
EndFunc   ;==>Example

Example 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 $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) ;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_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) ;draw the triangle

        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE

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