UDF > GDIPlus > GraphicsPath >


_GDIPlus_PathFlatten

Applique une transformation à un GraphicsPath et convertit chaque courbe en une séquence de segments de ligne connectés

#include <GDIPlus.au3>
_GDIPlus_PathFlatten ( $hPath [, $fFlatness = 0.25 [, $hMatrix = 0]] )

Paramètres

$hPath Handle de l'objet GraphicsPath
$fFlatness [optionnel] Nombre décimal qui spécifie l'erreur maximale entre la trajectoire et son approximation aplatie.
La réduction de la planéité augmente le nombre de segments de droite.
$hMatrix [optionnel] Handle de l'objet Matrix qui spécifie la transformation à appliquer aux points de données de la trajectoire

Valeur de retour

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

En relation

_GDIPlus_PathWarp

Voir aussi

Consultez GdipFlattenPath dans la Librairie MSDN.

Exemple

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

Example()

Func Example()
    Local $hGUI, $hGraphic, $hPen1, $hPen2, $hPath, $aPoints

    ; Crée une GUI
    $hGUI = GUICreate("GDI+", 800, 400)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet graphique à partir du handle de la fenêtre
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing
    _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF)

    $hPen1 = _GDIPlus_PenCreate(0xFFFFBB00, 2)
    $hPen2 = _GDIPlus_PenCreate(0xFF0000FF, 2)

    ; ellipse originale
    _GDIPlus_GraphicsDrawString($hGraphic, "original ellipse as bezier points", 10, 10)

    $hPath = _GDIPlus_PathCreate() ; Crée un objet path
    _GDIPlus_PathAddEllipse($hPath, 50, 50, 300, 300)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ; Dessine le Path avec le handle Graphic (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Ellipse aplatie
    _GDIPlus_GraphicsDrawString($hGraphic, "flattened ellipse as a sequence of straight lines", 410, 10)

    _GDIPlus_PathReset($hPath)
    _GDIPlus_PathAddEllipse($hPath, 450, 50, 300, 300)
    _GDIPlus_PathFlatten($hPath, 10)

    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen1) ; Dessine le Path avec le handle Graphic (GUI)

    $aPoints = _GDIPlus_PathGetPoints($hPath)
    For $i = 1 To $aPoints[0][0]
        _GDIPlus_GraphicsDrawEllipse($hGraphic, $aPoints[$i][0] - 4, $aPoints[$i][1] - 4, 8, 8, $hPen2)
    Next

    ; Boucle jusqu'à ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen1)
    _GDIPlus_PenDispose($hPen2)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example