Gets an array of points and types from a path
#include <GDIPlus.au3>
_GDIPlus_PathGetData ( $hPath )
$hPath | Pointer to a GraphicsPath object |
Success: | an array of points and types that specifies the endpoints and control points of the lines and bezier splines that are used to draw the path and the points types: [0][0] - Number of points and types [1][0] - Point 1 X position [1][1] - Point 1 Y position [1][2] - Point 1 type [n][0] - Point n X position [n][1] - Point n Y position [1][2] - Point n type Each point type is one of the following values: 0x00 - The point is the start of a figure 0x01 - The point is one of the two endpoints of a line 0x03 - The point is an endpoint or control point of a cubic bezier spline 0x20 - The point is a marker 0x80 - The point is the last point in a closed subpath (figure) |
Failure: | sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
Search GdipGetPathData in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hPath_Clone, $hFamily, $tLayout
Local $aBounds, $aPathData1, $aPathData2
$iW = 800
$iH = 300
$hGUI = GUICreate("GDI+", $iW, $iH)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
_GDIPlus_GraphicsClear($hGraphic, 0xFF000000)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF006600)
$hPen = _GDIPlus_PenCreate(0xFF00FF00, 2)
$hPath = _GDIPlus_PathCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial Black")
$tLayout = _GDIPlus_RectFCreate()
_GDIPlus_PathAddString($hPath, "AutoIt", $tLayout, $hFamily)
_GDIPlus_PathFlatten($hPath, 0.01)
$aBounds = _GDIPlus_PathGetWorldBounds($hPath)
$hPath_Clone = _GDIPlus_PathClone($hPath)
Local $aPoints[5][2]
$aPoints[0][0] = 4
$aPoints[1][0] = $iW * 0.2
$aPoints[1][1] = $iH * 0.3
$aPoints[2][0] = $iW * 0.8
$aPoints[2][1] = $iH * 0.3
$aPoints[3][0] = 0
$aPoints[3][1] = $iH
$aPoints[4][0] = $iW
$aPoints[4][1] = $iH
_GDIPlus_PathWarp($hPath, 0, $aPoints, $aBounds[0], $aBounds[1], $aBounds[2], $aBounds[3] + 2)
$aPoints[1][1] -= 12
$aPoints[2][1] -= 12
$aPoints[3][1] -= 32
$aPoints[4][1] -= 32
_GDIPlus_PathWarp($hPath_Clone, 0, $aPoints, $aBounds[0], $aBounds[1], $aBounds[2], $aBounds[3] + 2)
_GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush)
$aPathData1 = _GDIPlus_PathGetData($hPath)
$aPathData2 = _GDIPlus_PathGetData($hPath_Clone)
Local $aPolyGon[5][2] = [[4]], $iIdx
For $i = 1 To $aPathData1[0][0]
If $aPathData1[$i][2] = 0 Then $iIdx = $i
$aPolyGon[1][0] = $aPathData1[$i][0]
$aPolyGon[1][1] = $aPathData1[$i][1]
$aPolyGon[4][0] = $aPathData2[$i][0]
$aPolyGon[4][1] = $aPathData2[$i][1]
If BitAND($aPathData1[$i][2], 0x80) Then
$aPolyGon[2][0] = $aPathData1[$iIdx][0]
$aPolyGon[2][1] = $aPathData1[$iIdx][1]
$aPolyGon[3][0] = $aPathData2[$iIdx][0]
$aPolyGon[3][1] = $aPathData2[$iIdx][1]
Else
$aPolyGon[2][0] = $aPathData1[$i + 1][0]
$aPolyGon[2][1] = $aPathData1[$i + 1][1]
$aPolyGon[3][0] = $aPathData2[$i + 1][0]
$aPolyGon[3][1] = $aPathData2[$i + 1][1]
EndIf
_GDIPlus_GraphicsFillPolygon($hGraphic, $aPolyGon, $hBrush)
Next
_GDIPlus_BrushSetSolidColor($hBrush, 0xFF00AA00)
_GDIPlus_GraphicsFillPath($hGraphic, $hPath_Clone, $hBrush)
_GDIPlus_GraphicsDrawPath($hGraphic, $hPath_Clone, $hPen)
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_PathDispose($hPath)
_GDIPlus_PathDispose($hPath_Clone)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Example