PathGradientBrush ::SetTransform, méthode (gdipluspath.h)

La méthode PathGradientBrush ::SetTransform définit la matrice de transformation de ce pinceau de dégradé de chemin d’accès.

Syntaxe

Status SetTransform(
  [in] const Matrix *matrix
);

Paramètres

[in] matrix

Type : matrice* const

Pointeur vers un objet Matrix qui spécifie la matrice de transformation.

Valeur retournée

Type : État

Si la méthode réussit, elle retourne Ok, qui est un élément de l’énumération Status .

Si la méthode échoue, elle retourne l’un des autres éléments de l’énumération Status .

Remarques

Un objet PathGradientBrush a un objet GraphicsPath qui sert de chemin de limite pour le pinceau. Lorsque vous peignez avec un pinceau dégradé de chemin, seule la zone à l’intérieur du chemin de limite est remplie. Si la matrice de transformation du pinceau est définie pour représenter une transformation autre que l’identité, le chemin de limite est transformé en fonction de cette matrice pendant le rendu, et seule la zone à l’intérieur du chemin transformé est remplie.

La transformation s’applique uniquement pendant le rendu. Le chemin de limite stocké par l’objet PathGradientBrush n’est pas modifié par la méthode PathGradientBrush ::SetTransform .

Exemples

L’exemple suivant crée un objet PathGradientBrush basé sur un chemin triangulaire. La méthode Graphics ::FillRectangle utilise le pinceau de dégradé de chemin pour peindre un rectangle qui contient le chemin triangulaire. Ensuite, le code crée un objet Matrix qui représente une transformation composite (rotation, puis traduction) et transmet l’adresse de cet objet Matrix à la méthode PathGradientBrush ::SetTransform de l’objet PathGradientBrush . Le code appelle FillRectangle une deuxième fois pour peindre le même rectangle à l’aide du pinceau dégradé de chemin transformé.

VOID Example_SetTransform(HDC hdc)
{
   Graphics graphics(hdc);

   Point pts[] = {
      Point(0, 0), 
      Point(100, 0), 
      Point(100, 100)};

   Color cols[] = {
      Color(255, 255, 0, 0),  // red
      Color(255, 0, 255, 0),  // green
      Color(255, 0, 0, 0)};   // black

   INT count = 3;
   PathGradientBrush pthGrBrush(pts, 3);
   pthGrBrush.SetSurroundColors(cols, &count);

   // Fill an area with the path gradient brush (no transformation).
   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);

   // Set the transformation for the brush (rotate, then translate).
   Matrix matrix(0.0f, 1.0f, -1.0f, 0.0f, 150.0f, 60.0f);
   pthGrBrush.SetTransform(&matrix);
   
   // Fill the same area with the transformed path gradient brush.
   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);  
}

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows XP, Windows 2000 Professionnel [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête gdipluspath.h (inclure Gdiplus.h)
Bibliothèque Gdiplus.lib
DLL Gdiplus.dll

Voir aussi

Pinceaux et formes remplies

Création d’un dégradé de chemin

Remplissage d’une forme avec un dégradé de couleurs

Graphicspath

PathGradientBrush

PathGradientBrush ::GetTransform

PathGradientBrush ::MultiplyTransform

PathGradientBrush ::ResetTransform

PathGradientBrush ::RotateTransform

PathGradientBrush ::ScaleTransform

PathGradientBrush ::TranslateTransform