Méthode PathGradientBrush::GetCenterPoint(PointF*) (gdipluspath.h)

La méthode PathGradientBrush::GetCenterPoint obtient le point central de ce pinceau de dégradé de chemin.

Syntaxe

Status GetCenterPoint(
  PointF *point
);

Paramètres

point

Pointeur vers un objet PointF qui reçoit le point central.

Valeur retournée

Type:Status

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

Par défaut, le point central d’un objet PathGradientBrush se trouve au centroïde du chemin de limite du pinceau, mais vous pouvez définir le point central à n’importe quel emplacement, à l’intérieur ou à l’extérieur du chemin, en appelant la méthode SetCenterPoint de l’objet PathGradientBrush .

Exemples

L’exemple suivant illustre plusieurs méthodes de la classe PathGradientBrush , notamment PathGradientBrush::GetCenterPoint et PathGradientBrush::SetCenterColor. Le code crée un objet PathGradientBrush , puis définit la couleur centrale et la couleur de limite du pinceau. Le code appelle la méthode PathGradientBrush::GetCenterPoint pour déterminer le point central du dégradé de chemin d’accès, puis dessine une ligne de l’origine vers ce point central.

VOID Example_GetCenterPoint(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);

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

   // Obtain information about the path gradient brush.
   PointF centerPoint;
   pthGrBrush.GetCenterPoint(&centerPoint);

   // Draw a line from the origin to the center of the ellipse.
   Pen pen(Color(255, 0, 255, 0));
   graphics.DrawLine(&pen, PointF(0, 0), centerPoint);  
}

Configuration requise

   
En-tête gdipluspath.h

Voir aussi

Pinceaux et formes remplies

Color

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

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

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint, méthodes