UDF > GDIPlus > GraphicsPath >


_GDIPlus_PathAddCurve3

Ajoute une spline cardinale à la figure actuelle

#include <GDIPlus.au3>
_GDIPlus_PathAddCurve3 ( $hPath, $aPoints, $iOffset, $iNumOfSegments [, $nTension = 0.5] )

Paramètres

$hPath Handle de l'objet GraphicsPath
$aPoints Tableau de points qui définit la spline cardinale:
    [0][0] - Nombre de points
    [1][0] - Point 1, position X
    [1][1] - Point 1, position Y
    [2][0] - Point 2, position X
    [2][1] - Point 2, position Y
    [n][0] - Point n, position X
    [n][1] - Point n, position Y
$iOffset Index de l'élément du tableau $aPoints qui est utilisé comme premier point de la spline cardinale, c'est l'index du point spécifique dans le tableau moins 1
$iNumOfSegments Nombre de segments dans la spline cardinale. Les segments relient les points consécutifs du tableau
$nTension [optionnel] Nombre réel positif ou nul qui contrôle la longueur et la courbure de la courbe.
Plus la valeur augmente, plus la courbure augmente.

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur ($GPID_ERR*).

Remarque

La spline cardinale est une courbe qui passe par un sous-ensemble (spécifié par les paramètres $iOffset et $iNumOfSegments) des points du tableau

En relation

_GDIPlus_PathAddCurve, _GDIPlus_PathAddCurve2

Voir aussi

Consultez GdipAddPathCurve3 dans la Librairie MSDN.

Exemple

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

Global $g_hGUI, $g_hGraphics, $g_hBmp_Buffer, $g_hGfx_Buffer, $g_hPen, $g_hPen2, $g_hPath, $g_hPath2

Example()

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

    Local Const $iW = 400, $iH = 400

    $g_hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; Crée un objet graphique à partir du handle de la fenêtre
    $g_hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($g_hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing

    $g_hPen = _GDIPlus_PenCreate(0xFF8800AA, 2)
    $g_hPen2 = _GDIPlus_PenCreate(0xFFFFDD00, 3)

    $g_hPath = _GDIPlus_PathCreate() ; Crée un objet path

    Local $aPoints[201][2] = [[200]], $iRadius = 0
    For $i = 1 To $aPoints[0][0]
        $aPoints[$i][0] = Cos($i / 3.14) * $iRadius + $iW / 2
        $aPoints[$i][1] = Sin($i / 3.14) * $iRadius + $iH / 2
        $iRadius += 1
    Next

    _GDIPlus_PathAddCurve($g_hPath, $aPoints)

    $g_hPath2 = _GDIPlus_PathCreate() ; Crée un objet path
    Local $iOff = 1, $iNum = 4
    While Sleep(20)
        _GDIPlus_PathReset($g_hPath2)
        _GDIPlus_PathAddCurve3($g_hPath2, $aPoints, $iOff, $iNum)

        $iOff += 1
        If $iOff > $aPoints[0][0] - $iNum Then $iOff = 1

        _GDIPlus_GraphicsClear($g_hGfx_Buffer, 0xFF000000)
        _GDIPlus_GraphicsDrawPath($g_hGfx_Buffer, $g_hPath, $g_hPen) ; Dessine le Path avec le handle Graphic (GUI)
        _GDIPlus_GraphicsDrawPath($g_hGfx_Buffer, $g_hPath2, $g_hPen2) ; Dessine le Path avec le handle Graphic (GUI)
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBmp_Buffer, 0, 0)
    WEnd
EndFunc   ;==>Example

Func _Exit()
    ; Nettoie les ressources
    _GDIPlus_PathDispose($g_hPath)
    _GDIPlus_PathDispose($g_hPath2)
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_PenDispose($g_hPen2)
    _GDIPlus_GraphicsDispose($g_hGfx_Buffer)
    _GDIPlus_BitmapDispose($g_hBmp_Buffer)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit