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

PathGradientBrush::SetBlend メソッドは、このパス グラデーション ブラシのブレンド係数とブレンド位置を設定します。

構文

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

パラメーター

[in] blendFactors

種類: REAL*

ブレンド係数の配列へのポインター。 配列内の各数値は、0 ~ 1 の範囲にする必要があります。

[in] blendPositions

種類: REAL*

ブレンド位置の配列へのポインター。 配列内の各数値は、0 ~ 1 の範囲にする必要があります。

[in] count

型: INT

blendFactors 配列内の要素の数を指定する整数。 これは、 blendPositions 配列内の要素の数と同じです。

戻り値

種類: 状態

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

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

解説

PathGradientBrush オブジェクトには、境界パスと中心点があります。 パス グラデーション ブラシで領域を塗りつぶすと、境界パスから中心点に移動すると、色が徐々に変化します。 既定では、色は距離に直線的に関連付けられますが、 PathGradientBrush::SetBlend メソッドを呼び出すことで、色と距離の関係をカスタマイズできます。

次の例では、楕円に基づいて PathGradientBrush オブジェクトを作成します。 このコードでは、PathGradientBrush オブジェクトの PathGradientBrush::SetBlend メソッドを呼び出して、ブラシのブレンド 係数とブレンド位置のセットを確立します。 次に、コードはパス グラデーション ブラシを使用して楕円を塗りつぶします。

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

要件

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

関連項目

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

Color

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

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

Graphicspath

PathGradientBrush

PathGradientBrush::GetBlend

PathGradientBrush::GetBlendCount