UDF > GDIPlus > Pen >


_GDIPlus_PenSetColor

Définit la couleur d'un crayon

#include <GDIPlus.au3>
_GDIPlus_PenSetColor ( $hPen, $iARGB )

Paramètres

$hPen Handle de l'objet Pen
$iARGB Composantes de couleur du crayon: Alpha, Rouge, Vert et Bleu

Valeur de retour

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

En relation

_GDIPlus_PenGetColor

Voir aussi

Cherchez GdipSetPenColor dans la Library MSDN.

Exemple

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

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+ test", 640, 480)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hPen = _GDIPlus_PenCreate(0xFF101010)
    _GDIPlus_GraphicsDrawLine($hGraphics, 40, 40, 600, 440, $hPen) ; Trace une ligne de test pour montrer l'effet du lissage (par défaut pas de lissage)
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit le mode lissage (filtre 8 X 4)
    _GDIPlus_PenSetColor($hPen, 0xFF000080)
    _GDIPlus_GraphicsDrawLine($hGraphics, 600, 40, 40, 440, $hPen) ; Trace une ligne de test pour montrer l'effet de lissage
    MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))

    If @OSBuild > 5999 Then
        _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_ANTIALIAS8X8) ; Définnit le mode lissage (filtre 8 X 8)
        _GDIPlus_GraphicsDrawEllipse($hGraphics, 220, 140, 200, 200, $hPen) ; Trace une ligne de test pour montrer l'effet du lissage
        MsgBox($MB_SYSTEMMODAL, "", "Smoothing enabled: " & _GDIPlus_GraphicsGetSmoothingMode($hGraphics))
    EndIf

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

Example()

Func Example()
    Local $hGUI = GUICreate("GDI+", 600, 300)
    GUISetState(@SW_SHOW)

    _GDIPlus_Startup()
    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Local $hBmp_Buffer = _GDIPlus_BitmapCreateFromGraphics(600, 300, $hGraphics)
    Local $hGfx_Buffer = _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
    _GDIPlus_GraphicsSetSmoothingMode($hGfx_Buffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
    _GDIPlus_GraphicsClear($hGfx_Buffer, 0xFF000000)

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

    Local $hPath = _GDIPlus_PathCreate()
    Local $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, 1)
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $tLayout = _GDIPlus_RectFCreate(0, 0, 600, 300)
    _GDIPlus_PathAddString($hPath, "AutoIt rulez!", $tLayout, $hFamily, 0, 112, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontFamilyDispose($hFamily)

    Local $hIter = _GDIPlus_PathIterCreate($hPath)
    Local $hSubPath = _GDIPlus_PathCreate(); Path pour obtenir les figures du sous-tracé

    Local $iPointCount
    Do
        _GDIPlus_PathReset($hSubPath)

        ; Par exemple La lettre A est composé de deux sous-tracés - comparer avec _GDIPlus_PathIterNextSubpathPath
        $iPointCount = _GDIPlus_PathIterNextMarkerPath($hIter, $hSubPath)
        If $iPointCount > 0 Then
            _GDIPlus_PenSetColor($hPen, BitOR(0xFF000000, Random(0xFF, 0xFFFFFF, 1)))
            _GDIPlus_BrushSetSolidColor($hBrush, BitOR(0xFF000000, Random(0xFF, 0xFFFFFF, 1)))

            _GDIPlus_GraphicsFillPath($hGfx_Buffer, $hSubPath, $hBrush)
            _GDIPlus_GraphicsDrawPath($hGfx_Buffer, $hSubPath, $hPen)
        EndIf
    Until $iPointCount = 0

    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)

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

    ; Nettoie les ressources
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example