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

PathGradientBrush::GetSurroundColors メソッドは、このパス グラデーション ブラシに現在指定されているサラウンドカラーを取得します。

構文

Status GetSurroundColors(
  [in]      Color *colors,
  [in, out] INT   *count
);

パラメーター

[in] colors

種類: *

囲み色を受け取る配列へのポインター。

[in, out] count

型: INT*

入力時に、要求された色の数を指定する整数へのポインター。 メソッドが成功した場合、このパラメーターは出力時に取得された色の数を受け取ります。 メソッドが失敗した場合、このパラメーターは値を受け取りません。

戻り値

種類: 状態

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

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

注釈

パス グラデーション ブラシには、境界パスと中心点があります。 中心点は 1 つの色に設定されますが、境界上の複数のポイントに異なる色を指定できます。 たとえば、中心の色に赤を指定し、境界上の個別の点に青、緑、黄色を指定するとします。 その後、境界に沿って移動すると、色が徐々に青から緑から黄色に変わり、青色に戻ります。 境界上の任意の点から中心点に直線に沿って移動すると、その境界ポイントの色から赤に色が変わります。

次の例では、3 つのポイントの配列で定義された三角形のパスに基づいて PathGradientBrush オブジェクトを作成します。 このコードでは、PathGradientBrush オブジェクトの PathGradientBrush::SetSurroundColors メソッドを呼び出して、三角形を定義する各ポイントの色を指定します。 PathGradientBrush::GetSurroundColorCount メソッドは、現在のサラウンド カラーの数 (ブラシの境界パスに指定された色) を決定します。 次に、囲み色の配列を受け取るのに十分な大きさのバッファーを割り当て、そのバッファーを埋めるために PathGradientBrush::GetSurroundColors を呼び出します。 最後に、コードは小さな四角形に各ブラシのサラウンドカラーを塗りつぶします。

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

   // Create a path gradient brush and set its surround colors.
   Point pts[] = {
      Point(20, 20), 
      Point(100, 20), 
      Point(100, 100)};

   Color cols[] = {
      Color(255, 255, 0, 0),  // red
      Color(255, 0, 255, 0),  // green
      Color(255, 0, 0, 0)};   // black

   INT count = 3;
   PathGradientBrush pthGrBrush(pts, 3);
   pthGrBrush.SetSurroundColors(cols, &count);
   
   // Obtain information about the path gradient brush.
   INT colorCount = pthGrBrush.GetSurroundColorCount();
   Color* colors = new Color[colorCount];
   pthGrBrush.GetSurroundColors(colors, &colorCount);

   // Fill a small square with each of the surround 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;
}

要件

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

こちらもご覧ください

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

Color

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

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

PathGradientBrush

PathGradientBrush::GetSurroundColorCount

PathGradientBrush::SetSurroundColors