Matrix.Scale 方法

定义

通过预先计算比例向量,将指定的比例向量应用到此 Matrix

重载

Scale(Single, Single)

通过预先计算比例向量,将指定的比例向量应用到此 Matrix

Scale(Single, Single, MatrixOrder)

使用指定的顺序,将指定的比例向量(scaleXscaleY)应用到此 Matrix

Scale(Single, Single)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

通过预先计算比例向量,将指定的比例向量应用到此 Matrix

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 轴方向缩放的值。

scaleY
Single

Matrix 在 Y 轴方向缩放的值。

示例

有关示例,请参见 Scale(Single, Single, MatrixOrder)

适用于

Scale(Single, Single, MatrixOrder)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

使用指定的顺序,将指定的比例向量(scaleXscaleY)应用到此 Matrix

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 轴方向缩放的值。

scaleY
Single

Matrix 在 Y 轴方向缩放的值。

order
MatrixOrder

一个 MatrixOrder,指定应用比例向量到此 Matrix 的顺序(追加或预先计算)。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse事件Paint对象。 此代码执行以下操作:

  • 在 (蓝色矩形) 应用缩放转换之前,将矩形绘制到屏幕。

  • 创建一个矩阵,并在 x 轴上按 3 缩放,在 y 轴上按 2 缩放。

  • 将此矩阵转换应用于矩形。

  • 将转换后的矩形绘制到屏幕 (红色矩形) 。

请注意,红色矩形在 x 轴中缩放了 3,在 y 轴中缩放了 2,包括矩形的左上角 (矩形) 的起点。

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

适用于