PathGradientBrush.MultiplyTransform 方法

定义

通过预先计算指定的 Matrix,将表示此 PathGradientBrush 的局部几何转换的 Matrix 与指定的 Matrix 相乘。Multiplies the Matrix that represents the local geometric transform of this PathGradientBrush by the specified Matrix by prepending the specified Matrix.

重载

MultiplyTransform(Matrix)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of brush's transformation matrix multiplied by another matrix.

MultiplyTransform(Matrix, MatrixOrder)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of the brush's transformation matrix multiplied by another matrix.

MultiplyTransform(Matrix)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of brush's transformation matrix multiplied by another matrix.

public:
 void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix -> unit

参数

matrix
Matrix

将与画笔的当前变换矩阵相乘的 MatrixThe Matrix that will be multiplied by the brush's current transformation matrix.

示例

有关示例,请参阅MultiplyTransformFor an example, see MultiplyTransform.

MultiplyTransform(Matrix, MatrixOrder)

通过画笔的变换矩阵与其他的矩阵相乘的乘积更新该画笔的变换矩阵。Updates the brush's transformation matrix with the product of the brush's transformation matrix multiplied by another matrix.

public:
 void MultiplyTransform(System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::MatrixOrder order);
public void MultiplyTransform (System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order);
member this.MultiplyTransform : System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.MatrixOrder -> unit

参数

matrix
Matrix

将与画笔的当前变换矩阵相乘的 MatrixThe Matrix that will be multiplied by the brush's current transformation matrix.

order
MatrixOrder

一个 MatrixOrder,它指定两个矩阵相乘的顺序。A MatrixOrder that specifies in which order to multiply the two matrices.

示例

下面的代码示例是为与 Windows 窗体一起使用而设计的,它需要 PaintEventArgseOnPaint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. 该代码执行下列操作:The code performs the following actions:

  • 创建图形路径并向其添加一个矩形。Creates a graphics path and adds a rectangle to it.

  • 从路径点创建一个 PathGradientBrush (在此示例中,点构成一个矩形,但它可以是大多数形状)。Creates a PathGradientBrush from the path points (in this example, the points form a rectangle, but it could be most any shape).

  • 将中间颜色设置为红色,将周围颜色设置为蓝色。Sets the center color to red and the surrounding color to blue.

  • 在应用乘变换之前,将 PathGradientBrush 绘制到屏幕上。Draws the PathGradientBrush to the screen prior to applying the multiply transform.

  • 创建将画笔90旋转的矩阵,并在两个轴将其转换为100。Creates s matrix that rotates the brush 90 degrees and translates it by 100 in both axes.

  • 使用 MultiplyTransform 方法将此矩阵应用于画笔。Applies this matrix to the brush by using the MultiplyTransform method.

  • 在屏幕上绘制画笔。Draws the brush to the screen.

public:
   void MultiplyTransformExample( PaintEventArgs^ e )
   {
      // Create a graphics path and add an rectangle.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      Rectangle rect = Rectangle(20,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 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 = gcnew 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 );
   }
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);
}
Public Sub MultiplyTransformExample(ByVal 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

适用于