次の方法で共有


PathGradientBrush.MultiplyTransform メソッド

指定された Matrix を先に適用するように指定して、 PathGradientBrush のローカル ジオメトリック変換を表す Matrix オブジェクトに、この指定された Matrix を掛け合わせます。

オーバーロードの一覧

ブラシの変換行列に別の行列を掛け合わせることにより、そのブラシの変換行列を更新します。

[Visual Basic] Overloads Public Sub MultiplyTransform(Matrix)

[C#] public void MultiplyTransform(Matrix);

[C++] public: void MultiplyTransform(Matrix*);

[JScript] public function MultiplyTransform(Matrix);

ブラシの変換行列に別の行列を掛け合わせることにより、そのブラシの変換行列を更新します。

[Visual Basic] Overloads Public Sub MultiplyTransform(Matrix, MatrixOrder)

[C#] public void MultiplyTransform(Matrix, MatrixOrder);

[C++] public: void MultiplyTransform(Matrix*, MatrixOrder);

[JScript] public function MultiplyTransform(Matrix, MatrixOrder);

使用例

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

  • グラフィックス パスを作成し、そのパスに四角形を追加します。
  • パスを形成する複数の点から PathGradientBrush オブジェクトを作成します。この例では、これらの点は四角形を形成していますが、どのような図形を形成する点でもかまいません。
  • 中心の色を赤に設定し、周囲の色を青に設定します。
  • 乗算変換を適用する前に、 PathGradientBrush を画面に描画します。
  • このブラシを 90°回転させ、両軸方向に 100 ずつ平行移動した行列を作成します。
  • MultiplyTransform メソッドを使用して、この行列をブラシに適用します。
  • 画面にブラシを描画します。

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

 
Public Sub MultiplyTransformExample(e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath()
Dim rect As New Rectangle(20, 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 transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Create a new matrix that rotates by 90 degrees, and
' translates by 100 in each direction.
Dim myMatrix As New Matrix(0, 1, - 1, 0, 100, 100)
' Apply the transform to the brush.
myPGBrush.MultiplyTransform(myMatrix, MatrixOrder.Append)
' Draw the brush to the screen again after applying the
' transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300)
End Sub
        
[C#] 
public void MultiplyTransformExample(PaintEventArgs e)
{
// Create a graphics path and add an rectangle.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(20, 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 transformation.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Create a new matrix that rotates by 90 degrees, and
// translates by 100 in each direction.
Matrix myMatrix = new Matrix(0, 1, -1, 0, 100, 100);
// Apply the transform to the brush.
myPGBrush.MultiplyTransform(myMatrix, MatrixOrder.Append);
// Draw the brush to the screen again after applying the
// transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 300);
}
        

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

参照

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