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

La méthode PathGradientBrush::SetBlend définit les facteurs de fusion et les positions de fusion de ce pinceau de dégradé de chemin.

Syntaxe

Status SetBlend(
  [in] const REAL *blendFactors,
  [in] const REAL *blendPositions,
  [in] INT        count
);

Paramètres

[in] blendFactors

Type : REAL*

Pointeur vers un tableau de facteurs de fusion. Chaque nombre du tableau doit être compris entre 0 et 1.

[in] blendPositions

Type : REAL*

Pointeur vers un tableau de positions de fusion. Chaque nombre du tableau doit être compris entre 0 et 1.

[in] count

Type : INT

Entier qui spécifie le nombre d’éléments dans le tableau blendFactors . Il s’agit du même nombre d’éléments dans le tableau blendPositions .

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 .

Notes

Un objet PathGradientBrush a un chemin de limite et un point central. Lorsque vous remplissez une zone avec un pinceau de dégradé de chemin, la couleur change progressivement à mesure que vous passez du chemin de limite au point central. Par défaut, la couleur est liée de manière linéaire à la distance, mais vous pouvez personnaliser la relation entre la couleur et la distance en appelant la méthode PathGradientBrush::SetBlend .

Exemples

L’exemple suivant crée un objet PathGradientBrush basé sur une ellipse. Le code appelle la méthode PathGradientBrush::SetBlend de l’objet PathGradientBrush pour établir un ensemble de facteurs de fusion et de positions de fusion pour le pinceau. Ensuite, le code utilise le pinceau de dégradé de chemin pour remplir l’ellipse.

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

   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);

   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);

   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));

   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);

   // Set blend factors and positions for the path gradient brush.
   REAL fac[] = {
      0.0f, 
      0.4f,     // 40 percent of the way from aqua to blue
      0.8f,     // 80 percent of the way from aqua to blue
      1.0f};

   REAL pos[] = {
      0.0f, 
      0.3f,   // 30 percent of the way from the boundary to the center
      0.7f,   // 70 percent of the way from the boundary to the center
      1.0f};

   pthGrBrush.SetBlend(fac, pos, 4);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);  
}

Spécifications

   
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

Color

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

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

Graphicspath

PathGradientBrush

PathGradientBrush::GetBlend

PathGradientBrush::GetBlendCount