Matrix.Scale 方法

定義

在尺規向量前面加上小數位數向量,將指定的尺規向量套用至這個 Matrix

多載

Scale(Single, Single)

在尺規向量前面加上小數位數向量,將指定的尺規向量套用至這個 Matrix

Scale(Single, Single, MatrixOrder)

使用指定的順序,將指定的尺規向量 (scaleXscaleY) 套用至這個 Matrix

Scale(Single, Single)

來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
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)

來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
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 Forms 搭配使用,而且需要 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

適用於