PathGradientBrush::GetCenterPoint(PointF*) メソッド (gdipluspath.h)

PathGradientBrush::GetCenterPoint メソッドは、このパス グラデーション ブラシの中心点を取得します。

構文

Status GetCenterPoint(
  PointF *point
);

パラメーター

point

中心点を受け取る PointF オブジェクトへのポインター。

戻り値

Type:Status

メソッドが成功した場合は、 Status 列挙の要素である Ok を返します。

メソッドが失敗した場合は、 Status 列挙体の他の要素のいずれかを返します。

解説

既定では、PathGradientBrush オブジェクトの中心点はブラシの境界パスの重心にありますが、PathGradientBrush オブジェクトの SetCenterPoint メソッドを呼び出すことで、パスの内側または外側の任意の場所に中心点を設定できます。

次の例では、PathGradientBrush::GetCenterPoint や PathGradientBrush::SetCenterColor など、PathGradientBrush クラスのいくつかのメソッドを示します。 このコードでは 、PathGradientBrush オブジェクトを作成し、ブラシの中心の色と境界の色を設定します。 このコードは PathGradientBrush::GetCenterPoint メソッドを呼び出してパス グラデーションの中心点を決定し、原点からその中心点までの線を描画します。

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);  
}

必要条件

   
Header gdipluspath.h

関連項目

ブラシと図形の塗りつぶし

Color

パス グラデーションの作成

色のグラデーションで図形を塗りつぶす

PathGradientBrush

PathGradientBrush::GetCenterColor

PathGradientBrush::SetCenterColor

PathGradientBrush::SetCenterPoint メソッド