Matrix.Shear 方法

定义

通过预先计算切变向量将指定的切变向量应用到此 MatrixApplies the specified shear vector to this Matrix by prepending the shear vector.

重载

Shear(Single, Single)

通过预先计算切变变换,将指定的切变向量应用到此 MatrixApplies the specified shear vector to this Matrix by prepending the shear transformation.

Shear(Single, Single, MatrixOrder)

按指定的顺序,将指定的切变向量应用到此 MatrixApplies the specified shear vector to this Matrix in the specified order.

Shear(Single, Single)

通过预先计算切变变换,将指定的切变向量应用到此 MatrixApplies 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)

参数

shearX
Single

水平切变因子。The horizontal shear factor.

shearY
Single

垂直切变因子。The vertical shear factor.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要 PaintEventArgs e 一个 Paint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, 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.

  • 创建 Matrix ,并使用它来设置的世界坐标变换 GraphicsCreates 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. 请注意,在设置转换) 之前 (绘制的绿色矩形会直接使用调用中提供的坐标 DrawRectangleNotice 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. 请注意,会将矩形的底部移动 (剪切) 在 x 轴上,将矩形高度的两倍,从而形成平行四边形。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

注解

仅当其中一个参数为0时,才使用此方法中应用的转换。The transformation applied in this method is a pure shear only if one of the parameters is 0. 应用于原点的矩形,当 shearY 系数为0时,转换会将下边缘水平移动 shearX 矩形的高度。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. shearX 系数为0时,它会将该矩形的宽度垂直向右移动 shearYWhen 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. 例如,如果两个因素都为1,则转换是单数 (因此 noninvertible) ,将整个平面挤压为一个直线。For example, if both factors are 1, the transformation is singular (hence noninvertible), squeezing the entire plane to a single line.

适用于

Shear(Single, Single, MatrixOrder)

按指定的顺序,将指定的切变向量应用到此 MatrixApplies 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)

参数

shearX
Single

水平切变因子。The horizontal shear factor.

shearY
Single

垂直切变因子。The vertical shear factor.

order
MatrixOrder

一个 MatrixOrder,指定应用切变所采用的顺序(追加或预先计算)。A MatrixOrder that specifies the order (append or prepend) in which the shear is applied.

示例

有关示例,请参见 Shear(Single, Single)For an example, see Shear(Single, Single).

注解

仅当其中一个参数为0时,才使用此方法中应用的转换。The transformation applied in this method is a pure shear only if one of the parameters is 0. 应用于原点的矩形,当 shearY 系数为0时,转换会将下边缘水平移动 shearX 矩形的高度。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. shearX 系数为0时,它会将该矩形的宽度垂直向右移动 shearYWhen 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. 例如,如果两个因素都为1,则转换是单数 (因此 noninvertible) ,将整个平面挤压为一个直线。For example, if both factors are 1, the transformation is singular (hence noninvertible), squeezing the entire plane to a single line.

适用于