PathGradientBrush::GetFocusScales メソッド (gdipluspath.h)

PathGradientBrush::GetFocusScales メソッドは、このパス グラデーション ブラシのフォーカス スケールを取得します。

構文

Status GetFocusScales(
  [out] REAL *xScale,
  [out] REAL *yScale
);

パラメーター

[out] xScale

種類: REAL*

x フォーカス スケール値を受け取る REAL へのポインター。

[out] yScale

種類: REAL*

y フォーカス スケール値を受け取る REAL へのポインター。

戻り値

種類: 状態

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

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

解説

既定では、パス グラデーションの中心の色は中心点にあります。 PathGradientBrush::SetFocusScales を呼び出すと、中心点を囲むパスに沿って中心の色が表示されるように指定できます。 たとえば、境界パスが三角形で、中心点がその三角形の重心にあるとします。 また、境界の色が赤で、中心の色が青であると仮定します。 フォーカススケールを (0.2, 0.2) に設定すると、中心点を囲む小さな三角形の境界に沿って色が青になります。 その小さな三角形は、x 方向に 0.2、y 方向に 0.2 の係数でスケーリングされたメイン境界パスです。 パス グラデーション ブラシを使用してペイントすると、大きな三角形の境界から小さな三角形の境界に移動すると、色が赤から青に徐々に変化します。 小さな三角形の内側の領域は青で塗りつぶされます。

次の例では、三角形のパスに基づいて PathGradientBrush オブジェクトを作成します。 このコードでは、パス グラデーション ブラシのフォーカス スケールを (0.2, 0.2) に設定し、パス グラデーション ブラシを使用して、三角形のパスを含む領域を塗りつぶします。 最後に、PathGradientBrush オブジェクトの PathGradientBrush::GetFocusScales メソッドを呼び出して、x フォーカス スケールと y フォーカス スケールの値を取得します。

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

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

   // No GraphicsPath object is created. The PathGradientBrush
   // object is constructed directly from the array of points.
   PathGradientBrush pthGrBrush(points, 3);

   Color colors[] = {
      Color(255, 255, 0, 0),    // red
      Color(255, 0, 0, 255)};   // blue

   REAL relativePositions[] = {
      0.0f,    // red at the boundary of the outer triangle
      1.0f};   // blue at the boundary of the inner triangle

   pthGrBrush.SetInterpolationColors(colors, relativePositions, 2);

   // The inner triangle is formed by scaling the outer triangle
   // about its centroid. The scaling factor is 0.2 in both
   // the x and y directions.
   pthGrBrush.SetFocusScales(0.2f, 0.2f);

   // Fill a rectangle that is larger than the triangle
   // specified in the Point array. The portion of the
   // rectangle outside the triangle will not be painted.
   graphics.FillRectangle(&pthGrBrush, 0, 0, 200, 200);

   // Obtain information about the path gradient brush.
   REAL xScale = 0.0f;
   REAL yScale = 0.0f;
   pthGrBrush.GetFocusScales(&xScale, &yScale);

   // The value of xScale is now 0.2.
   // The value of yScale is now 0.2. 
}

要件

   
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdipluspath.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

関連項目

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

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

Graphicspath

PathGradientBrush

PathGradientBrush::SetFocusScales