Adds a closed cardinal spline to a path
#include <GDIPlus.au3>
_GDIPlus_PathAddClosedCurve2 ( $hPath, $aPoints [, $nTension = 0.5] )
$hPath | Pointer to a GraphicsPath object |
$aPoints | Array of points that define the 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 | [optional] Nonnegative real number that controls the length of the curve and how the curve bends. A value of 0 specifies that the spline is a sequence of straight lines. As the value increases, the curve becomes fuller. |
Success: | True. |
Failure: | False and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
A cardinal spline is a curve that passes through each point in the array.
Search GdipAddPathClosedCurve2 in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $hGUI, $hGraphic, $hBrush, $hPen, $hPen2, $hPath
; Create GUI
$hGUI = GUICreate("GDI+", 800, 300)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;Create a graphics object from a window handle
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;Sets the graphics object rendering quality (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() ;Create new path object
_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) ;Fill path to graphics handle (GUI)
_GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ;Draw path to graphics handle (GUI)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_PathDispose($hPath)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PenDispose($hPen)
_GDIPlus_PenDispose($hPen2)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Example