UDF > GDIPlus > GraphicsPath >


_GDIPlus_PathTransform

Multiplie chacun des points de données d'un tracé (GraphicsPath) par une matrice spécifiée

#include <GDIPlus.au3>
_GDIPlus_PathTransform ( $hPath, $hMatrix )

Paramètres

$hPath Handle de l'objet GraphicsPath
$hMatrix Handle de l'objet Matrix qui définit la transformation

Valeur de retour

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

Voir aussi

Consultez GdipTransformPath dans la Librairie MSDN.

Exemple

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

Example()

Func Example()
    Local $iW, $iH, $hGUI, $hGraphic, $hBrush, $hPen, $hPath, $hFamily, $tLayout, $hMatrix, $aBounds

    ; Crée une GUI
    $iW = 640
    $iH = 220
    $hGUI = GUICreate("GDI+", $iW, $iH)
    GUISetState(@SW_SHOW)

    ; Dessine une chaîne en utilisant un Path
    _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, 0xFF000000)

    $hBrush = _GDIPlus_BrushCreateSolid(0xFFDD2200)
    $hPen = _GDIPlus_PenCreate(0xFFFFBB00, 2)

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

    $hFamily = _GDIPlus_FontFamilyCreate("Arial") ; Crée un objet FontFamily
    $tLayout = _GDIPlus_RectFCreate() ; Crée une chaîne encadrée par un rectangle de position X=0, Y=0
    _GDIPlus_PathAddString($hPath, "Fit to Window", $tLayout, $hFamily) ; Ajoute le contour de la chaîne au Path

    ; Transforme le Path pour l'adapter à la fenêtre
    $aBounds = _GDIPlus_PathGetWorldBounds($hPath) ; Obtient le rectangle de délimitation du Path
    $hMatrix = _GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($hMatrix, -$aBounds[0], -$aBounds[1]) ; Matrice de translation pour l'offset du rectangle de délimitation
    _GDIPlus_MatrixScale($hMatrix, $iW / $aBounds[2], $iH / $aBounds[3], True) ; Matrice de mise à l'échelle
    _GDIPlus_PathTransform($hPath, $hMatrix) ; Translate et met à l'échelle le Path

    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Dessine le Path avec le handle Graphic (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Dessine le Path avec le handle Graphic (GUI)

    ; Transforme le tracé pour le centrer
    _GDIPlus_PathReset($hPath) ; Réinitialise le Path (supprime chaîne précédente)
    _GDIPlus_PathAddString($hPath, "Center", $tLayout, $hFamily, 0, 100, 0) ; Ajoute le contour de la chaîne au Path

    $aBounds = _GDIPlus_PathGetWorldBounds($hPath)
    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0) ; Réinitialise la matrice
    _GDIPlus_MatrixTranslate($hMatrix, ($iW / 2) - $aBounds[0] - ($aBounds[2] / 2), ($iH / 2) - $aBounds[1] - ($aBounds[3] / 2))
    _GDIPlus_PathTransform($hPath, $hMatrix) ; Translate (offset) le Path

    _GDIPlus_BrushSetSolidColor($hBrush, 0x7F004488)
    _GDIPlus_PenSetColor($hPen, 0xFF00AAFF)
    _GDIPlus_GraphicsFillPath($hGraphic, $hPath, $hBrush) ; Dessine le Path avec le handle Graphic (GUI)
    _GDIPlus_GraphicsDrawPath($hGraphic, $hPath, $hPen) ; Dessine le Path avec le handle Graphic (GUI)

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

    ; Nettoie les ressources
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_PathDispose($hPath)
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example