Pen.ScaleTransform 方法

定义

按指定因素缩放局部几何转换。 此方法将缩放矩阵前面追加到转换。

重载

ScaleTransform(Single, Single)

按指定因素缩放局部几何转换。 此方法将缩放矩阵前面追加到转换。

ScaleTransform(Single, Single, MatrixOrder)

按指定顺序按指定因子缩放局部几何转换。

ScaleTransform(Single, Single)

Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs

按指定因素缩放局部几何转换。 此方法将缩放矩阵前面追加到转换。

public:
 void ScaleTransform(float sx, float sy);
public void ScaleTransform (float sx, float sy);
member this.ScaleTransform : single * single -> unit
Public Sub ScaleTransform (sx As Single, sy As Single)

参数

sx
Single

在 x 轴方向缩放转换所依据的因素。

sy
Single

在 y 轴方向缩放转换所依据的因素。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

创建 Pen

使用笔绘制矩形。

在 x 轴方向将笔缩放 2 次。

绘制第二个矩形来演示差异。

public:
   void ScaleTransform_Example1( PaintEventArgs^ e )
   {
      
      // Create a Pen object.
      Pen^ scalePen = gcnew Pen( Color::Black,5.0f );
      
      // Draw a rectangle with scalePen.
      e->Graphics->DrawRectangle( scalePen, 10, 10, 100, 100 );
      
      // Scale scalePen by 2X in the x-direction.
      scalePen->ScaleTransform( 2, 1 );
      
      // Draw a second rectangle with rotatePen.
      e->Graphics->DrawRectangle( scalePen, 120, 10, 100, 100 );
   }
public void ScaleTransform_Example1(PaintEventArgs e)
{
             
    // Create a Pen object.
    Pen scalePen = new Pen(Color.Black, 5);
             
    // Draw a rectangle with scalePen.
    e.Graphics.DrawRectangle(scalePen, 10, 10, 100, 100);
             
    // Scale scalePen by 2X in the x-direction.
    scalePen.ScaleTransform(2, 1);
             
    // Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(scalePen, 120, 10, 100, 100);
}
Public Sub ScaleTransform_Example1(ByVal e As PaintEventArgs)

    ' Create a Pen object.
    Dim scalePen As New Pen(Color.Black, 5)

    ' Draw a rectangle with scalePen.
    e.Graphics.DrawRectangle(scalePen, 10, 10, 100, 100)

    ' Scale scalePen by 2X in the x-direction.
    scalePen.ScaleTransform(2, 1)

    ' Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(scalePen, 120, 10, 100, 100)
End Sub

适用于

ScaleTransform(Single, Single, MatrixOrder)

Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs
Source:
Pen.cs

按指定顺序按指定因子缩放局部几何转换。

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

参数

sx
Single

在 x 轴方向缩放转换所依据的因素。

sy
Single

在 y 轴方向缩放转换所依据的因素。

order
MatrixOrder

一个 MatrixOrder,指定是追加还是追加缩放矩阵。

示例

下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。 该代码执行以下操作:

  • 创建 Pen

  • 使用笔绘制矩形。

  • 在 x 轴方向将笔缩放 2 次。

  • 绘制第二个矩形来演示差异。

public:
   void ScaleTransform_Example2( PaintEventArgs^ e )
   {
      
      // Create a Pen object.
      Pen^ scalePen = gcnew Pen( Color::Black,5.0f );
      
      // Draw a rectangle with scalePen.
      e->Graphics->DrawRectangle( scalePen, 10, 10, 100, 100 );
      
      // Scale scalePen by 2X in the x-direction.
      scalePen->ScaleTransform( 2, 1, MatrixOrder::Prepend );
      
      // Draw a second rectangle with rotatePen.
      e->Graphics->DrawRectangle( scalePen, 120, 10, 100, 100 );
   }
public void ScaleTransform_Example2(PaintEventArgs e)
{
             
    // Create a Pen object.
    Pen scalePen = new Pen(Color.Black, 5);
             
    // Draw a rectangle with scalePen.
    e.Graphics.DrawRectangle(scalePen, 10, 10, 100, 100);
             
    // Scale scalePen by 2X in the x-direction.
    scalePen.ScaleTransform(2, 1, MatrixOrder.Prepend);
             
    // Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(scalePen, 120, 10, 100, 100);
}
Public Sub ScaleTransform_Example2(ByVal e As PaintEventArgs)

    ' Create a Pen object.
    Dim scalePen As New Pen(Color.Black, 5)

    ' Draw a rectangle with scalePen.
    e.Graphics.DrawRectangle(scalePen, 10, 10, 100, 100)

    ' Scale scalePen by 2X in the x-direction.
    scalePen.ScaleTransform(2, 1, MatrixOrder.Prepend)

    ' Draw a second rectangle with rotatePen.
    e.Graphics.DrawRectangle(scalePen, 120, 10, 100, 100)
End Sub

适用于