UDF > GDIPlus > Graphics >


_GDIPlus_GraphicsDrawClosedCurve2

Dessine une spline cardinale fermée

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawClosedCurve2 ( $hGraphics, $aPoints, $nTension [, $hPen = 0] )

Paramètres

$hGraphics Handle de l'objet Graphics
$aPoints Tableau de points qui spécifie les coordonnées de la spline cardinale fermée. Le tableau doit être de la forme suivante:
    [0][0] - Nombre de points
    [1][0] - Point 1 - abscisse X
    [1][1] - Point 1 - ordonnée Y
    [2][0] - Point 2 - abscisse X
    [2][1] - Point 2 - ordonnée Y
    [n][0] - Point n - abscisse X
    [n][1] - Point n - ordonnée Y
$nTension Nombre qui spécifie comment la courbe sera tendue sur les points/td>
$hPen [optionnel] Handle de l'objet Pen qui est utilisé pour dessiner les splines. Si 0, un crayon noir qui trace des lignes continues de largeur 1

Valeur de retour

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

Remarque

Une spline cardinale est une courbe sans point anguleux qui passe par un ensemble donné de points.

En relation

_GDIPlus_GraphicsDrawClosedCurve

Voir aussi

Consultez GdipDrawClosedCurve2 dans la Librairie MSDN.

Exemple

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

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

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

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

    $g_hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une GUI de test
    GUISetBkColor($iBgColor, $g_hGUI) ; Définit la couleur de fond de la GUI
    GUISetState(@SW_SHOW)

    ; Crée un graphique dans un buffer pour lisser les mouvements des objets gfx
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ; Crée un objet graphique à partir d'un handle fenêtre
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing
    $g_hPen = _GDIPlus_PenCreate(0xFFFF8060, 2)
    _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)

    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 ; Coordonnée x du point
            $aPoints[$y * 5 + $x][1] = 150 + $x * 50 ; Coordonnée y du point
            $aPoints[$y * 5 + $x][2] = Random(-2, 2) ; x vecteur du point
            $aPoints[$y * 5 + $x][3] = Random(-2, 2) ; y vecteur du point
        Next
    Next

    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ; Efface bitmap pour repeindre
        _GDIPlus_GraphicsDrawClosedCurve2($g_hGfxCtxt, $aPoints, 1.25, $g_hPen) ; Dessine la courbe fermée
        _GDIPlus_GraphicsDrawImage($g_hGraphics, $g_hBitmap, 0, 0) ; Copie le bitmap sur le handle graphique (GUI)
        For $y = 1 To $aPoints[0][0]
            $aPoints[$y][0] += $aPoints[$y][2] ; Calcule la nouvelle position x
            If $aPoints[$y][0] < 0 Or $aPoints[$y][0] > $iWidth Then $aPoints[$y][2] *= -1 ; si bordure verticale est atteinte inverser vecteur x
            $aPoints[$y][1] += $aPoints[$y][3] ; Calcule la nouvelle position y
            If $aPoints[$y][1] < 0 Or $aPoints[$y][1] > $iHeight Then $aPoints[$y][3] *= -1 ; si la bordure horizontale est atteinte inverser y vecteur
        Next
    Until Not Sleep(30) ; Pause 30 ms pour éviter une utilisation élevée du processeur
EndFunc   ;==>Example

Func _Exit()
    ; Nettoie les ressources GDI+
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit