संपादित करें

इसके माध्यम से साझा किया गया


Matrix.Shear Method

Definition

Applies the specified shear vector to this Matrix by prepending the shear vector.

Overloads

Shear(Single, Single)

Applies the specified shear vector to this Matrix by prepending the shear transformation.

Shear(Single, Single, MatrixOrder)

Applies the specified shear vector to this Matrix in the specified order.

Shear(Single, Single)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

Applies the specified shear vector to this Matrix by prepending the shear transformation.

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)

Parameters

shearX
Single

The horizontal shear factor.

shearY
Single

The vertical shear factor.

Examples

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an Paint event object. The code performs the following action:

  • Draws a rectangle to the screen, using a green pen, prior to applying a scaling transform.

  • Creates a Matrix and uses it to set a world-coordinate transform for the Graphics.

  • Draws another rectangle using a red pen.

  • Draws an ellipse using a blue pen.

The result is a green rectangle, a red parallelogram and a transformed, blue ellipse. Notice that the green rectangle (drawn prior to setting the transform) directly uses the coordinates supplied in the DrawRectangle call. The other two figures are transformed prior to drawing. The rectangle is transformed to a parallelogram (red), and the ellipse (blue) is transformed to fit into the transformed parallelogram. Notice the bottom of the rectangle is moved (sheared) in the x-axis by a factor of two times the height of the rectangle, thus forming the parallelogram.

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

Remarks

The transformation applied in this method is a pure shear only if one of the parameters is 0. Applied to a rectangle at the origin, when the shearY factor is 0, the transformation moves the bottom edge horizontally by shearX times the height of the rectangle. When the shearX factor is 0, it moves the right edge vertically by shearY times the width of the rectangle. Caution is in order when both parameters are nonzero, because the results are hard to predict. For example, if both factors are 1, the transformation is singular (hence noninvertible), squeezing the entire plane to a single line.

Applies to

Shear(Single, Single, MatrixOrder)

Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs
Source:
Matrix.cs

Applies the specified shear vector to this Matrix in the specified order.

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)

Parameters

shearX
Single

The horizontal shear factor.

shearY
Single

The vertical shear factor.

order
MatrixOrder

A MatrixOrder that specifies the order (append or prepend) in which the shear is applied.

Examples

For an example, see Shear(Single, Single).

Remarks

The transformation applied in this method is a pure shear only if one of the parameters is 0. Applied to a rectangle at the origin, when the shearY factor is 0, the transformation moves the bottom edge horizontally by shearX times the height of the rectangle. When the shearX factor is 0, it moves the right edge vertically by shearY times the width of the rectangle. Caution is in order when both parameters are nonzero, because the results are hard to predict. For example, if both factors are 1, the transformation is singular (hence noninvertible), squeezing the entire plane to a single line.

Applies to