次の方法で共有


LinearGradientBrush.SetBlendTriangularShape メソッド

中心の色、および両端の単色への線形の減色が設定されている線形グラデーションを作成します。

オーバーロードの一覧

中心の色、および両端の単色への線形の減色が設定されている線形グラデーションを作成します。

[Visual Basic] Overloads Public Sub SetBlendTriangularShape(Single)

[C#] public void SetBlendTriangularShape(float);

[C++] public: void SetBlendTriangularShape(float);

[JScript] public function SetBlendTriangularShape(float);

中心の色、および両端の単色への線形の減色が設定されている線形グラデーションを作成します。

[Visual Basic] Overloads Public Sub SetBlendTriangularShape(Single, Single)

[C#] public void SetBlendTriangularShape(float, float);

[C++] public: void SetBlendTriangularShape(float, float);

[JScript] public function SetBlendTriangularShape(float, float);

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 OnPaint イベントのオブジェクトである PaintEventArgs e が必要です。このコードは次のアクションを実行します。

  • 新しい LinearGradientBrush オブジェクトを作成します。
  • このブラシを使用して、左から右へ線形に色が変化するグラデーションを持つ楕円を画面に描画します。
  • LinearGradientBrush オブジェクトを、中央に頂点のある三角形に変換します。
  • 変換されたブラシを使用して、画面に 2 番目の楕円を描画します。

[Visual Basic, C#] 下の楕円のグラデーションは、青から赤に変化し、さらに青に戻ります。

[Visual Basic, C#] メモ   ここでは、SetBlendTriangularShape のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
Public Sub SetBlendTriangularShapeExample(e As PaintEventArgs)
' Create a LinearGradientBrush.
Dim myRect As New Rectangle(20, 20, 200, 100)
Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
Color.Red, 0F, True)
' Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, myRect)
' Create a triangular shaped brush with the peak at the center
' of the drawing area.
myLGBrush.SetBlendTriangularShape(0.5F, 1F)
' Use the triangular brush to draw a second ellipse.
myRect.Y = 150
e.Graphics.FillEllipse(myLGBrush, myRect)
End Sub
        
[C#] 
private void SetBlendTriangularShapeExample(PaintEventArgs e)
{
// Create a LinearGradientBrush.
Rectangle myRect = new Rectangle(20, 20, 200, 100);
LinearGradientBrush myLGBrush = new LinearGradientBrush(
myRect,
Color.Blue,
Color.Red,
0.0f,
true);
// Draw an ellipse to the screen using the LinearGradientBrush.
e.Graphics.FillEllipse(myLGBrush, myRect);
// Create a triangular shaped brush with the peak at the center
// of the drawing area.
myLGBrush.SetBlendTriangularShape(.5f, 1.0f);
// Use the triangular brush to draw a second ellipse.
myRect.Y = 150;
e.Graphics.FillEllipse(myLGBrush, myRect);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

LinearGradientBrush クラス | LinearGradientBrush メンバ | System.Drawing.Drawing2D 名前空間