語言

Matrix.Shear 方法

定義

透過在剪切向量前加上指定的剪切向量來應用於此 Matrix 。

多載

名稱 Description
Shear(Single, Single)

透過在剪切變換前加上指定的剪切向量來應用於此 Matrix 。

Shear(Single, Single, MatrixOrder)

依規定順序將指定的剪切向量應用於此 Matrix 。

Shear(Single, Single)

來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs

透過在剪切變換前加上指定的剪切向量來應用於此 Matrix 。

public:
 void Shear(float shearX, float shearY);
public void Shear(float shearX, float shearY);
member this.Shear : single * single -> unit
Public Sub Shear (shearX As Single, shearY As Single)

參數

shearX
Single

水平剪切因子。

shearY
Single

垂直剪切因子。

範例

以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 Paint 事件物件。 程式代碼會執行下列動作:

  • 在套用縮放轉換前,用綠色筆在螢幕上畫一個矩形。

  • 建立 aMatrix,並用它來設定一個世界座標轉換。Graphics

  • 用紅筆畫另一個長方形。

  • 用藍色筆畫一個橢圓形。

結果是一個綠色長方形、一個紅色平行四邊形和一個變換後的藍色橢圓。 請注意,綠色矩形(在設定轉換前繪製)直接使用呼叫中 DrawRectangle 提供的座標。 另外兩個人物在繪製前會先變形。 矩形會變換成平行四邊形(紅色),橢圓(藍色)則會變換以符合變換後的平行四邊形。 注意矩形底部在 x 軸上被移動(剪切)了矩形高度的兩倍,形成了平行四邊形。

public:
   void MatrixShearExample( PaintEventArgs^ e )
   {
      Matrix^ myMatrix = gcnew Matrix;
      myMatrix->Shear( 2, 0 );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Green ), 0, 0, 100, 50 );
      e->Graphics->MultiplyTransform( myMatrix );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red ), 0, 0, 100, 50 );
      e->Graphics->DrawEllipse( gcnew Pen( Color::Blue ), 0, 0, 100, 50 );
   }
public void MatrixShearExample(PaintEventArgs e)
{
    Matrix myMatrix = new Matrix();
    myMatrix.Shear(2, 0);
    e.Graphics.DrawRectangle(new Pen(Color.Green), 0, 0, 100, 50);
    e.Graphics.MultiplyTransform(myMatrix);
    e.Graphics.DrawRectangle(new Pen(Color.Red), 0, 0, 100, 50);
    e.Graphics.DrawEllipse(new Pen(Color.Blue), 0, 0, 100, 50);
}
Public Sub MatrixShearExample(ByVal e As PaintEventArgs)
    Dim myMatrix As New Matrix
    myMatrix.Shear(2, 0)
    e.Graphics.DrawRectangle(New Pen(Color.Green), 0, 0, 100, 50)
    e.Graphics.MultiplyTransform(myMatrix)
    e.Graphics.DrawRectangle(New Pen(Color.Red), 0, 0, 100, 50)
    e.Graphics.DrawEllipse(New Pen(Color.Blue), 0, 0, 100, 50)
End Sub

備註

此方法中所應用的變換僅在參數為0時才是純剪切。 當變換作用於原點的矩形時,當因子 shearY 為0時,變換會使底邊水平移動,乘 shearX 以矩形高度。 當因子 shearX 為 0 時,右邊垂直移動矩 shearY 形寬度乘以。 當兩個參數都非零時需謹慎,因為結果難以預測。 例如,若兩個因子皆為1,則變換為奇異(因此不可逆),將整個平面壓縮為一條直線。

適用於

Shear(Single, Single, MatrixOrder)

來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs
來源:
Matrix.cs

依規定順序將指定的剪切向量應用於此 Matrix 。

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

參數

shearX
Single

水平剪切因子。

shearY
Single

垂直剪切因子。

order
MatrixOrder

MatrixOrder A 指定剪切施加的順序(附加或前置)。

範例

如需範例,請參閱 Shear(Single, Single)。

備註

此方法中所應用的變換僅在參數為0時才是純剪切。 當變換作用於原點的矩形時,當因子 shearY 為0時,變換會使底邊水平移動,乘 shearX 以矩形高度。 當因子 shearX 為 0 時,右邊垂直移動矩 shearY 形寬度乘以。 當兩個參數都非零時需謹慎,因為結果難以預測。 例如,若兩個因子皆為1,則變換為奇異(因此不可逆),將整個平面壓縮為一條直線。

適用於