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

PathGradientBrush::GetInterpolationColors メソッドは、このパス グラデーション ブラシに現在指定されている既定の色とブレンド位置を取得します。

構文

Status GetInterpolationColors(
  [out] Color *presetColors,
  [out] REAL  *blendPositions,
  [in]  INT   count
);

パラメーター

[out] presetColors

種類: *

事前設定された色を受け取る配列へのポインター。 presetColors 配列内の特定のインデックスの色は、blendPositions 配列内の同じインデックスのブレンド位置に対応します。

[out] blendPositions

種類: REAL*

ブレンド位置を受け取る配列へのポインター。 各ブレンド位置は 0 から 1 までの数値で、0 はグラデーションの境界を示し、1 は中心点を示します。 0 ~ 1 のブレンド位置は、境界から中心点までの距離の一定の割合であるすべてのポイントのセットを示します。 たとえば、ブレンド位置が 0.7 の場合、境界から中心点までの 70% のポイントのセットが示されます。

[in] count

型: INT

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

戻り値

種類: 状態

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

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

注釈

単純なパス グラデーション ブラシには、境界の色と中心の色の 2 つの色があります。 このようなブラシを使用してペイントすると、境界パスから中心点に移動すると、色が境界の色から中心の色に徐々に変化します。 より複雑なグラデーションを作成するには、事前設定された色の配列とブレンド位置の配列を指定します。

PathGradientBrush::GetInterpolationColors メソッドを呼び出す前に、2 つのバッファーを割り当てる必要があります。1 つは事前設定された色の配列を保持し、もう 1 つはブレンド位置の配列を保持します。 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColorCount メソッドを呼び出して、これらのバッファーの必要なサイズを決定できます。 カラー バッファーのサイズは、 PathGradientBrush::GetInterpolationColorCountsizeof(Color) を掛けた戻り値です。 位置バッファーのサイズは、 PathGradientBrush::GetInterpolationColorCount の 値に sizeof( REAL) を掛けた値です。

次の例では、三角形の パスから PathGradientBrush オブジェクトを作成します。 このコードでは、プリセットの色を赤、青、アクアに設定し、ブレンド位置を 0、0.6、1 に設定します。 このコードは、 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColorCount メソッドを呼び出して ブラシに現在設定されているプリセット色の数を取得します。 次に、コードは 2 つのバッファーを割り当てます。1 つは事前設定された色の配列を保持し、もう 1 つはブレンド位置の配列を保持します。 PathGradientBrush オブジェクトの PathGradientBrush::GetInterpolationColors メソッドを呼び出すと、バッファーに事前設定された色とブレンド位置が設定されます。 最後に、コードは小さな四角形に各プリセットの色を塗りつぶします。

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

   // Create a path gradient brush from an array of points, and
   // set the interpolation colors for that brush.

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

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

   REAL pos[] = {
      0.0f,    // red at the boundary
      0.6f,    // blue 60 percent of the way from the boundary to the center
      1.0f};   // aqua at the center

   pthGrBrush.SetInterpolationColors(col, pos, 3);

   // Obtain information about the path gradient brush.
   INT colorCount = pthGrBrush.GetInterpolationColorCount();
   Color* colors = new Color[colorCount];
   REAL* positions = new REAL[colorCount];
   pthGrBrush.GetInterpolationColors(colors, positions, colorCount);

   // Fill a small square with each of the interpolation colors.
   SolidBrush solidBrush(Color(255, 255, 255, 255));

   for(INT j = 0; j < colorCount; ++j)
   {
      solidBrush.SetColor(colors[j]);
      graphics.FillRectangle(&solidBrush, 15*j, 0, 10, 10);
   }

   delete [] colors;
   delete [] positions; 
}

要件

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

こちらもご覧ください

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

Color

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

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

PathGradientBrush

PathGradientBrush::GetInterpolationColorCount

PathGradientBrush::SetInterpolationColors