Function Reference


Creates a closed cardinal spline from an array of points and uses a brush to fill the interior of the spline

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


$hGraphics Pointer to a Graphics object
$aPoints Array of points that specify the coordinates of the closed cardinal spline:
    [0][0] - Number of points
    [1][0] - Point 1 X position
    [1][1] - Point 1 Y position
    [2][0] - Point 2 X position
    [2][1] - Point 2 Y position
    [n][0] - Point n X position
    [n][1] - Point n Y position
$nTension Number that specifies how tightly the spline bends as it passes through the points
$hBrush [optional] Handle to a brush object that is used to fill the cardinal spline. If 0, a black brush will be used.
$iFillMode [optional] Fill mode of the interior of the spline:
    0 - The areas are filled according to the even-odd parity rule
    1 - The areas are filled according to the nonzero winding rule

Return Value

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



See Also

Search GdipFillClosedCurve2 in MSDN Library.


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

Global $g_hGUI, $g_hGfxCtxt, $g_hBitmap, $g_hGraphics, $g_hBrush


Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

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

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

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hBrush = _GDIPlus_BrushCreateSolid(0xFF80FF60)

    Local $aPoints[11][4], $x, $y
    $aPoints[0][0] = 10

    For $y = 0 To 1
        For $x = 1 To 5
            $aPoints[$y * 5 + $x][0] = 100 + 300 * $y + 50 ;x coordinate of the point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ;y coordinate of the point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ;x vector of the point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ;y vector of the point

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsFillClosedCurve2($g_hGfxCtxt, $aPoints, 0.75, $g_hBrush) ;draw closed curve
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ;copy bitmap to graphic handle (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ;calculate new x position
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ;if vertical border is reached invert x vector
            $aPoints[$y][1] += $aPoints[$y][3] ;calculate new y position
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ;if horizontal border is reached invert y vector
    Until Not Sleep(30) ;sleep 30 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
EndFunc   ;==>_Exit