中心の色から周囲の各色に向かって線形に減色していくグラデーションを作成します。
Overloads Public Sub SetBlendTriangularShape( _
ByVal focus As Single, _ ByVal scale As Single _)
[C#]
public void SetBlendTriangularShape(floatfocus,floatscale);
[C++]
public: void SetBlendTriangularShape(floatfocus,floatscale);
[JScript]
public function SetBlendTriangularShape(
focus : float,scale : float);
パラメータ
- focus
パスの中心から境界までの半径に沿って、中心の色の輝度が最も高くなる位置を指定する 0 ~ 1 の値。この値が 1 (既定値) の場合、パスの中心の輝度が最も高くなります。 - scale
境界の色とブレンドされる中心の色の最大輝度を指定する 0 ~ 1 の値。この値が 1 の場合は、中心の色の輝度はできる限り高くなります。この値が既定値です。
解説
SurroundColors 配列に複数の色が含まれている場合は、この配列内の最初の色が終了色として使用されます。この配列に指定されている色は、ブラシの境界パス上にある個別の点に使用される色です。
既定では、パス グラデーションの境界から中心に移動するにつれて、境界に指定した色から中心に指定した色へと色が徐々に変化していきます。このメソッドを呼び出すことにより、境界の色と中心の色について位置やブレンドをカスタマイズできます。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- グラフィックス パスを作成し、そのパスに四角形を追加します。
- パスを形成する複数の点から PathGradientBrush を作成します。この例では、これらの点は四角形を形成していますが、どのような図形を形成する点でもかまいません。
- 中心の色を赤に設定し、周囲の色を青に設定します。
- ブレンド変換を適用する前に、 PathGradientBrush を画面に描画します。
- ブラシの SetBlendTriangularShape メソッドを使用して、そのブラシにブレンド変換を適用します。
- TranslateTransform メソッドを呼び出して、画面に先に描画された四角形と重複しないように、ブラシ四角形を移動します。
- 変換後のブラシの四角形を画面に描画します。
[Visual Basic, C#] 中心の色 (赤) の輝度が最大になるのは、パスの中心から境界に向かう距離の半分の位置です。
Public Sub SetBlendTriangularShapeExample(e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath()
Dim rect As New Rectangle(100, 20, 100, 50)
myPath.AddRectangle(rect)
' Get the path's array of points.
Dim myPathPointArray As PointF() = myPath.PathPoints
' Create a path gradient brush.
Dim myPGBrush As New PathGradientBrush(myPathPointArray)
' Set the color span.
myPGBrush.CenterColor = Color.Red
Dim mySurroundColor As Color() = {Color.Blue}
myPGBrush.SurroundColors = mySurroundColor
' Draw the brush to the screen prior to blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Set the Blend factors.
myPGBrush.SetBlendTriangularShape(0.5F, 1F)
' Move the brush down by 100 by Applying the translate
' transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub
[C#]
public void SetBlendTriangularShapeExample(PaintEventArgs e)
{
// Create a graphics path and add a rectangle.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(100, 20, 100, 50);
myPath.AddRectangle(rect);
// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;
// Create a path gradient brush.
PathGradientBrush myPGBrush = new
PathGradientBrush(myPathPointArray);
// Set the color span.
myPGBrush.CenterColor = Color.Red;
Color[] mySurroundColor = {Color.Blue};
myPGBrush.SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to the blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Set the Blend factors.
myPGBrush.SetBlendTriangularShape(0.5f, 1.0f);
// Move the brush down by 100 by Applying the translate
// transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transforms.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
PathGradientBrush クラス | PathGradientBrush メンバ | System.Drawing.Drawing2D 名前空間 | PathGradientBrush.SetBlendTriangularShape オーバーロードの一覧