語言

Graphics.ScaleTransform 方法

定義

將指定的縮放操作應用於該 Graphics 轉換矩陣,方法是將指定的縮放運算置於物件的轉換矩陣前。

多載

名稱 Description
ScaleTransform(Single, Single)

將指定的縮放操作應用於該 Graphics 轉換矩陣,方法是將指定的縮放運算置於物件的轉換矩陣前。

ScaleTransform(Single, Single, MatrixOrder)

依指定順序對其 Graphics 轉換矩陣套用指定的縮放運算。

ScaleTransform(Single, Single)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

將指定的縮放操作應用於該 Graphics 轉換矩陣,方法是將指定的縮放運算置於物件的轉換矩陣前。

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 Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:

  • 將 Windows Form 的世界轉換矩陣旋轉 30 度。

  • 在 x 方向上將矩陣縮放為 3 倍,y 方向則為 1 倍,方法是先進行縮放轉換。

  • 用藍色筆畫出一個縮放旋轉的長方形。

結果仍然是長方形。

public:
   void ScaleTransformFloat( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to scale, prepending to world transform.
      e->Graphics->ScaleTransform( 3.0F, 1.0F );

      // Draw scaled, rotated rectangle to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
   }
private void ScaleTransformFloat(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to scale, prepending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F);

    // Draw scaled, rotated rectangle to screen.
    e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloat(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to scale, prepending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F)

    ' Draw scaled, rotated rectangle to screen.
    e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub

備註

縮放運算是將變換矩陣乘以一個元素為 (sx, sy, 1) 的對角矩陣。 此方法將 的 Graphics 轉換矩陣前置於縮放矩陣之上。

適用於

ScaleTransform(Single, Single, MatrixOrder)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

依指定順序對其 Graphics 轉換矩陣套用指定的縮放運算。

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 Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:

  • 將 Windows Form 的世界轉換矩陣旋轉 30 度。

  • 透過附加縮放變換 Append 與構件,將該矩陣在 x 方向縮放 3 倍,y 方向 1 倍縮放。

  • 用藍色筆畫一個旋轉、縮放的矩形。

結果是一個平行四邊形。

public:
   void ScaleTransformFloatMatrixOrder( PaintEventArgs^ e )
   {
      // Set world transform of graphics object to rotate.
      e->Graphics->RotateTransform( 30.0F );

      // Then to scale, appending to world transform.
      e->Graphics->ScaleTransform( 3.0F, 1.0F, MatrixOrder::Append );

      // Draw rotated, scaled rectangle to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Blue,3.0f ), 50, 0, 100, 40 );
   }
private void ScaleTransformFloatMatrixOrder(PaintEventArgs e)
{

    // Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F);

    // Then to scale, appending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append);

    // Draw rotated, scaled rectangle to screen.
    e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
Private Sub ScaleTransformFloatMatrixOrder(ByVal e As PaintEventArgs)

    ' Set world transform of graphics object to rotate.
    e.Graphics.RotateTransform(30.0F)

    ' Then to scale, appending to world transform.
    e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append)

    ' Draw rotated, scaled rectangle to screen.
    e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub

備註

縮放運算是將變換矩陣乘以一個元素為 (sx, sy, 1) 的對角矩陣。 此方法依參數在 的變換矩陣 Graphics 前加上縮放矩陣 order 。

適用於