Graphics.MultiplyTransform 方法

定义

将此 Graphics 的世界转换乘以指定的 MatrixMultiplies the world transformation of this Graphics and specified the Matrix.

重载

MultiplyTransform(Matrix)

将此 Graphics 的世界转换乘以指定的 MatrixMultiplies the world transformation of this Graphics and specified the Matrix.

MultiplyTransform(Matrix, MatrixOrder)

以指定顺序将此 Graphics 的世界转换乘以指定的 MatrixMultiplies the world transformation of this Graphics and specified the Matrix in the specified order.

MultiplyTransform(Matrix)

将此 Graphics 的世界转换乘以指定的 MatrixMultiplies the world transformation of this Graphics and specified the 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
Public Sub MultiplyTransform (matrix As Matrix)

参数

matrix
Matrix

乘以世界变换的 4x4 Matrix4x4 Matrix that multiplies the world transformation.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个 transformMatrix 矩阵 (两个按两个恒等矩阵再加上一个零平移矢量) 。Creates a transformMatrix matrix (a two by two identity matrix plus a zero-translation vector).

  • 按向量 (200,100) 转换变换矩阵。Translates the transform matrix by a vector (200, 100).

  • 将 Windows 窗体的世界变换矩阵旋转30度,将30度的旋转矩阵向窗体的变换矩阵前面进行旋转。Rotates the world transformation matrix of the Windows Form by 30 degrees, prepends the rotation matrix for 30 degrees to the form's transformation matrix.

  • 将旋转世界变换矩阵乘以平移的 transformMatrix ,并将其前面预置 transformMatrix 到世界变换矩阵。Multiplies the rotated world transformation matrix by the translated transformMatrix, and prepends the transformMatrix to the world transformation matrix.

  • 绘制旋转的平移椭圆。Draws a rotated, translated ellipse.

public:
   void MultiplyTransformMatrix( PaintEventArgs^ e )
   {
      // Create transform matrix.
      Matrix^ transformMatrix = gcnew Matrix;

      // Translate matrix, prepending translation vector.
      transformMatrix->Translate( 200.0F, 100.0F );

      // Rotate transformation matrix of graphics object,
      // prepending rotation matrix.
      e->Graphics->RotateTransform( 30.0F );

      // Multiply (prepend to) transformation matrix of
      // graphics object to translate graphics transformation.
      e->Graphics->MultiplyTransform( transformMatrix );

      // Draw rotated, translated ellipse.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), -80, -40, 160, 80 );
   }
private void MultiplyTransformMatrix(PaintEventArgs e)
{

    // Create transform matrix.
    Matrix transformMatrix = new Matrix();

    // Translate matrix, prepending translation vector.
    transformMatrix.Translate(200.0F, 100.0F);

    // Rotate transformation matrix of graphics object,

    // prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F);

    // Multiply (prepend to) transformation matrix of

    // graphics object to translate graphics transformation.
    e.Graphics.MultiplyTransform(transformMatrix);

    // Draw rotated, translated ellipse.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
}
Private Sub MultiplyTransformMatrix(ByVal e As PaintEventArgs)

    ' Create transform matrix.
    Dim transformMatrix As New Matrix

    ' Translate matrix, prepending translation vector.
    transformMatrix.Translate(200.0F, 100.0F)

    ' Rotate transformation matrix of graphics object,

    ' prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F)

    ' Multiply (prepend to) transformation matrix of

    ' graphics object to translate graphics transformation.
    e.Graphics.MultiplyTransform(transformMatrix)

    ' Draw rotated, translated ellipse.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), -80, -40, 160, 80)
End Sub

注解

此方法将参数指定的矩阵前面预置 matrix ,使结果为 matrix x 世界转换。This method prepends the matrix specified by the matrix parameter, so that the result is matrix x world transformation.

适用于

MultiplyTransform(Matrix, MatrixOrder)

以指定顺序将此 Graphics 的世界转换乘以指定的 MatrixMultiplies the world transformation of this Graphics and specified the Matrix in the specified order.

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
Public Sub MultiplyTransform (matrix As Matrix, order As MatrixOrder)

参数

matrix
Matrix

乘以世界变换的 4x4 Matrix4x4 Matrix that multiplies the world transformation.

order
MatrixOrder

MatrixOrder 枚举的成员,它确定乘法的顺序。Member of the MatrixOrder enumeration that determines the order of the multiplication.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个 transformMatrix 矩阵 (两个按两个恒等矩阵再加上一个零平移矢量) 。Creates a transformMatrix matrix (a two by two identity matrix plus a zero-translation vector).

  • 按向量 (200,100) 转换变换矩阵。Translates the transform matrix by a vector (200, 100).

  • 将 Windows 窗体的世界变换矩阵旋转30度,将30度的旋转矩阵追加到窗体的变换矩阵。Rotates the world transformation matrix of the Windows Form by 30 degrees, prepending the rotation matrix for 30 degrees to the form's transformation matrix.

  • 将旋转世界变换矩阵乘以平移的 transformMatrix ,并将追加 transformMatrix 到世界变换矩阵。Multiplies the rotated world transformation matrix by the translated transformMatrix, appending the transformMatrix to the world transformation matrix.

  • 绘制旋转的平移椭圆。Draws a rotated, translated ellipse.

public:
   void MultiplyTransformMatrixOrder( PaintEventArgs^ e )
   {
      // Create transform matrix.
      Matrix^ transformMatrix = gcnew Matrix;

      // Translate matrix, prepending translation vector.
      transformMatrix->Translate( 200.0F, 100.0F );

      // Rotate transformation matrix of graphics object,
      // prepending rotation matrix.
      e->Graphics->RotateTransform( 30.0F );

      // Multiply (append to) transformation matrix of
      // graphics object to translate graphics transformation.
      e->Graphics->MultiplyTransform( transformMatrix, MatrixOrder::Append );

      // Draw rotated, translated ellipse.
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue,3.0f ), -80, -40, 160, 80 );
   }
private void MultiplyTransformMatrixOrder(PaintEventArgs e)
{

    // Create transform matrix.
    Matrix transformMatrix = new Matrix();

    // Translate matrix, prepending translation vector.
    transformMatrix.Translate(200.0F, 100.0F);

    // Rotate transformation matrix of graphics object,

    // prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F);

    // Multiply (append to) transformation matrix of

    // graphics object to translate graphics transformation.
    e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append);

    // Draw rotated, translated ellipse.
    e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
}
Private Sub MultiplyTransformMatrixOrder(ByVal e As PaintEventArgs)

    ' Create transform matrix.
    Dim transformMatrix As New Matrix

    ' Translate matrix, prepending translation vector.
    transformMatrix.Translate(200.0F, 100.0F)

    ' Rotate transformation matrix of graphics object,

    ' prepending rotation matrix.
    e.Graphics.RotateTransform(30.0F)

    ' Multiply (append to) transformation matrix of

    ' graphics object to translate graphics transformation.
    e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append)

    ' Draw rotated, translated ellipse.
    e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), -80, -40, 160, 80)
End Sub

注解

参数的值 Prepend order 指定乘法的顺序为 matrix x 世界转换。A value of Prepend for the order parameter specifies that the order of the multiplication is matrix x world transformation. 的值 Append order 指定乘法的顺序为世界转换 x matrixA value of Append for order specifies that the order of the multiplication is world transformation x matrix.

适用于