PathGradientBrush.SetBlendTriangularShape メソッド

定義

中心の色から周囲の色に向かって線形に減色していくグラデーションを作成します。

オーバーロード

SetBlendTriangularShape(Single)

中心の色から周囲の色に向かって線形に減色していくグラデーションを作成します。

SetBlendTriangularShape(Single, Single)

中心の色から周囲の各色に向かって線形に減色していくグラデーションを作成します。

SetBlendTriangularShape(Single)

中心の色から周囲の色に向かって線形に減色していくグラデーションを作成します。

public:
 void SetBlendTriangularShape(float focus);
public void SetBlendTriangularShape (float focus);
member this.SetBlendTriangularShape : single -> unit
Public Sub SetBlendTriangularShape (focus As Single)

パラメーター

focus
Single

パスの中心から境界までの半径に沿って、中心の色の輝度が最も高くなる位置を指定する 0 から 1 の値。 この値が 1 (既定値) の場合、パスの中心の輝度が最も高くなります。

例については、次を参照してください。 SetBlendTriangularShape.

注釈

配列に複数の SurroundColors 色がある場合は、配列の最初の色が終了色に使用されます。 この配列で指定された色は、ブラシの境界パス上の不連続ポイントに使用されます。

適用対象

SetBlendTriangularShape(Single, Single)

中心の色から周囲の各色に向かって線形に減色していくグラデーションを作成します。

public:
 void SetBlendTriangularShape(float focus, float scale);
public void SetBlendTriangularShape (float focus, float scale);
member this.SetBlendTriangularShape : single * single -> unit
Public Sub SetBlendTriangularShape (focus As Single, scale As Single)

パラメーター

focus
Single

パスの中心から境界までの半径に沿って、中心の色の輝度が最も高くなる位置を指定する 0 から 1 の値。 この値が 1 (既定値) の場合、パスの中心の輝度が最も高くなります。

scale
Single

境界の色とブレンドされる中心の色の最大輝度を指定する 0 から 1 の値。 この値が 1 の場合は、中心の色の輝度はできる限り高くなります。この値が既定値です。

次のコード例は、Windows フォームで使用するように設計されており、イベント オブジェクトがOnPaint必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • グラフィックス パスを作成し、四角形を追加します。

  • パスポイントから作成 PathGradientBrush します (この例では、ポイントは四角形を形成しますが、ほとんどの図形である可能性があります)。

  • 中心の色を赤に、周囲の色を青に設定します。

  • ブレンド変換を PathGradientBrush 適用する前に画面に描画します。

  • そのメソッドを使用して、ブラシにブレンド変換を SetBlendTriangularShape 適用します。

  • 前に TranslateTransform 画面に描画された四角形をオーバーレイしないように、ブラシの四角形を移動するメソッドを呼び出します。

  • 変換されたブラシの四角形が画面に描画されます。

最大の中心の色 (赤) は、パスの中心からパスの境界までの半分に配置されていることに注意してください。

public:
   void SetBlendTriangularShapeExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add a rectangle.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(100,20,100,50);
      myPath->AddRectangle( rect );

      // Get the path's array of points.
      array<PointF>^myPathPointArray = myPath->PathPoints;

      // Create a path gradient brush.
      PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );

      // Set the color span.
      myPGBrush->CenterColor = Color::Red;
      array<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 );
   }
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);
}
Public Sub SetBlendTriangularShapeExample(ByVal 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, 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)
End Sub

注釈

配列に複数の SurroundColors 色がある場合は、配列の最初の色が終了色に使用されます。 この配列で指定された色は、ブラシの境界パス上の不連続ポイントに使用される色です。

既定では、パスグラデーションの境界から中心点に移動すると、色は境界の色から中心の色に徐々に変化します。 このメソッドを呼び出すと、境界と中心の色の配置とブレンドをカスタマイズできます。

適用対象