Matrix.Scale 方法

定义

通过预先计算比例向量,将指定的比例向量应用到此 MatrixApplies the specified scale vector to this Matrix by prepending the scale vector.

重载

Scale(Single, Single)

通过预先计算比例向量,将指定的比例向量应用到此 MatrixApplies the specified scale vector to this Matrix by prepending the scale vector.

Scale(Single, Single, MatrixOrder)

使用指定的顺序,将指定的比例向量(scaleXscaleY)应用到此 MatrixApplies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.

Scale(Single, Single)

通过预先计算比例向量,将指定的比例向量应用到此 MatrixApplies the specified scale vector to this Matrix by prepending the scale vector.

public:
 void Scale(float scaleX, float scaleY);
public void Scale (float scaleX, float scaleY);
member this.Scale : single * single -> unit
Public Sub Scale (scaleX As Single, scaleY As Single)

参数

scaleX
Single

Matrix 在 X 轴方向缩放的值。The value by which to scale this Matrix in the x-axis direction.

scaleY
Single

Matrix 在 Y 轴方向缩放的值。The value by which to scale this Matrix in the y-axis direction.

示例

有关示例,请参见 Scale(Single, Single, MatrixOrder)For an example, see Scale(Single, Single, MatrixOrder).

适用于

Scale(Single, Single, MatrixOrder)

使用指定的顺序,将指定的比例向量(scaleXscaleY)应用到此 MatrixApplies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.

public:
 void Scale(float scaleX, float scaleY, System::Drawing::Drawing2D::MatrixOrder order);
public void Scale (float scaleX, float scaleY, System.Drawing.Drawing2D.MatrixOrder order);
member this.Scale : single * single * System.Drawing.Drawing2D.MatrixOrder -> unit
Public Sub Scale (scaleX As Single, scaleY As Single, order As MatrixOrder)

参数

scaleX
Single

Matrix 在 X 轴方向缩放的值。The value by which to scale this Matrix in the x-axis direction.

scaleY
Single

Matrix 在 Y 轴方向缩放的值。The value by which to scale this Matrix in the y-axis direction.

order
MatrixOrder

一个 MatrixOrder,指定应用比例向量到此 Matrix 的顺序(追加或预先计算)。A MatrixOrder that specifies the order (append or prepend) in which the scale vector is applied to this Matrix.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要 PaintEventArgs e 一个 Paint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an Paint event object. 此代码执行以下操作:The code performs the following actions:

  • 在应用缩放变换 (蓝色矩形) 之前,在屏幕上绘制矩形。Draws a rectangle to the screen prior to applying a scaling transform (the blue rectangle).

  • 创建一个矩阵并在 x 轴中将它缩放3个,并在 y 轴中缩放2。Creates a matrix and scales it by 3 in the x-axis and 2 in the y-axis.

  • 将此矩阵转换应用到矩形。Applies this matrix transform to the rectangle.

  • 将已转换的矩形绘制到) 红色矩形 (屏幕。Draws the transformed rectangle to the screen (the red rectangle).

请注意,红色矩形已按照 x 轴中的3倍和 y 轴中的2进行缩放,其中包括矩形的左上角 (矩形) 的起点。Notice that the red rectangle has been scaled by a factor of 3 in the x-axis and by 2 in the y-axis, including the upper left-hand corner of the rectangle (the beginning point of the rectangle).

public:
   void ScaleExample( PaintEventArgs^ e )
   {
      Pen^ myPen = gcnew Pen( Color::Blue,1.0f );
      Pen^ myPen2 = gcnew Pen( Color::Red,1.0f );

      // Draw the rectangle to the screen before applying the
      // transform.
      e->Graphics->DrawRectangle( myPen, 50, 50, 100, 100 );

      // Create a matrix and scale it.
      Matrix^ myMatrix = gcnew Matrix;
      myMatrix->Scale( 3, 2, MatrixOrder::Append );

      // Draw the rectangle to the screen again after applying the
      // transform.
      e->Graphics->Transform = myMatrix;
      e->Graphics->DrawRectangle( myPen2, 50, 50, 100, 100 );
   }
public void ScaleExample(PaintEventArgs e)
{
    Pen myPen = new Pen(Color.Blue, 1);
    Pen myPen2 = new Pen(Color.Red, 1);
             
    // Draw the rectangle to the screen before applying the
    // transform.
    e.Graphics.DrawRectangle(myPen, 50, 50, 100, 100);
             
    // Create a matrix and scale it.
    Matrix myMatrix = new Matrix();
    myMatrix.Scale(3, 2, MatrixOrder.Append);
             
    // Draw the rectangle to the screen again after applying the
    // transform.
    e.Graphics.Transform = myMatrix;
    e.Graphics.DrawRectangle(myPen2, 50, 50, 100, 100);
}
Public Sub ScaleExample(ByVal e As PaintEventArgs)
    Dim myPen As New Pen(Color.Blue, 1)
    Dim myPen2 As New Pen(Color.Red, 1)

    ' Draw the rectangle to the screen before applying the
    ' transform.
    e.Graphics.DrawRectangle(myPen, 50, 50, 100, 100)

    ' Create a matrix and scale it.
    Dim myMatrix As New Matrix
    myMatrix.Scale(3, 2, MatrixOrder.Append)

    ' Draw the rectangle to the screen again after applying the
    ' transform.
    e.Graphics.Transform = myMatrix
    e.Graphics.DrawRectangle(myPen2, 50, 50, 100, 100)
End Sub

适用于