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
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

要在 x 轴方向缩放此 Matrix 的值。

scaleY
Single

要在 y 轴方向缩放此 Matrix 的值。

示例

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

适用于

Scale(Single, Single, MatrixOrder)

Source:
Matrix.cs
Source:
Matrix.cs
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

要在 x 轴方向缩放此 Matrix 的值。

scaleY
Single

要在 y 轴方向缩放此 Matrix 的值。

order
MatrixOrder

一个 MatrixOrder,指定将缩放向量应用于此 Matrix的顺序(追加或追加)。

示例

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

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

  • 创建矩阵并将其缩放为 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

适用于