GraphicsPath.Warp 方法

定义

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

重载

Warp(PointF[], RectangleF)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix, WarpMode)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

Warp(PointF[], RectangleF)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

public:
 void Warp(cli::array <System::Drawing::PointF> ^ destPoints, System::Drawing::RectangleF srcRect);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect);
member this.Warp : System.Drawing.PointF[] * System.Drawing.RectangleF -> unit
Public Sub Warp (destPoints As PointF(), srcRect As RectangleF)

参数

destPoints
PointF[]

一个 PointF 结构的数组,它们定义由 srcRect 定义的矩形将变换到的平行四边形。An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. 该数组可以包含三个或四个元素。The array can contain either three or four elements. 如果该数组包含三个元素,则平行四边形的右下角位置的点可从前三个点导出。If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

一个 RectangleF,表示将变换为 destPoints 定义的平行四边形的矩形。A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

示例

有关示例,请参阅Warp(PointF[], RectangleF, Matrix, WarpMode, Single)For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Warp(PointF[], RectangleF, Matrix)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

public:
 void Warp(cli::array <System::Drawing::PointF> ^ destPoints, System::Drawing::RectangleF srcRect, System::Drawing::Drawing2D::Matrix ^ matrix);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix);
member this.Warp : System.Drawing.PointF[] * System.Drawing.RectangleF * System.Drawing.Drawing2D.Matrix -> unit

参数

destPoints
PointF[]

一个 PointF 结构的数组,它们定义由 srcRect 定义的矩形将变换到的平行四边形。An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. 该数组可以包含三个或四个元素。The array can contain either three or four elements. 如果该数组包含三个元素,则平行四边形的右下角位置的点可从前三个点导出。If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

一个 RectangleF,表示将变换为 destPoints 定义的平行四边形的矩形。A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

指定将应用于路径的几何变换的 MatrixA Matrix that specifies a geometric transform to apply to the path.

示例

有关示例,请参阅Warp(PointF[], RectangleF, Matrix, WarpMode, Single)For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Warp(PointF[], RectangleF, Matrix, WarpMode)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

public:
 void Warp(cli::array <System::Drawing::PointF> ^ destPoints, System::Drawing::RectangleF srcRect, System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::WarpMode warpMode);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode);
member this.Warp : System.Drawing.PointF[] * System.Drawing.RectangleF * System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.WarpMode -> unit

参数

destPoints
PointF[]

一个 PointF 结构的数组,该数组定义由 srcRect 定义的矩形将变换到的平行四边形。An array of PointF structures that defines a parallelogram to which the rectangle defined by srcRect is transformed. 该数组可以包含三个或四个元素。The array can contain either three or four elements. 如果该数组包含三个元素,则平行四边形的右下角位置的点可从前三个点导出。If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

一个 RectangleF,表示将变换为 destPoints 定义的平行四边形的矩形。A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

指定将应用于路径的几何变换的 MatrixA Matrix that specifies a geometric transform to apply to the path.

warpMode
WarpMode

一个 WarpMode 枚举,它指定此扭曲操作是使用透视模式还是双线性模式。A WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.

示例

有关示例,请参阅Warp(PointF[], RectangleF, Matrix, WarpMode, Single)For an example, see Warp(PointF[], RectangleF, Matrix, WarpMode, Single).

Warp(PointF[], RectangleF, Matrix, WarpMode, Single)

对此 GraphicsPath 应用由一个矩形和一个平行四边形定义的扭曲变换。Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.

public:
 void Warp(cli::array <System::Drawing::PointF> ^ destPoints, System::Drawing::RectangleF srcRect, System::Drawing::Drawing2D::Matrix ^ matrix, System::Drawing::Drawing2D::WarpMode warpMode, float flatness);
public void Warp (System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness);
member this.Warp : System.Drawing.PointF[] * System.Drawing.RectangleF * System.Drawing.Drawing2D.Matrix * System.Drawing.Drawing2D.WarpMode * single -> unit

参数

destPoints
PointF[]

一个 PointF 结构的数组,它们定义由 srcRect 定义的矩形将变换到的平行四边形。An array of PointF structures that define a parallelogram to which the rectangle defined by srcRect is transformed. 该数组可以包含三个或四个元素。The array can contain either three or four elements. 如果该数组包含三个元素,则平行四边形的右下角位置的点可从前三个点导出。If the array contains three elements, the lower-right corner of the parallelogram is implied by the first three points.

srcRect
RectangleF

一个 RectangleF,表示将变换为 destPoints 定义的平行四边形的矩形。A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.

matrix
Matrix

指定将应用于路径的几何变换的 MatrixA Matrix that specifies a geometric transform to apply to the path.

warpMode
WarpMode

一个 WarpMode 枚举,它指定此扭曲操作是使用透视模式还是双线性模式。A WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.

flatness
Single

一个介于 0 到 1 之间的值,它指定如何展平最终路径。A value from 0 through 1 that specifies how flat the resulting path is. 有关更多信息,请参见 Flatten() 方法。For more information, see the Flatten() methods.

示例

下面的代码示例是为与 Windows 窗体一起使用而设计的,它需要 PaintEventArgseOnPaint 事件对象。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, an OnPaint event object. 该代码执行下列操作:The code performs the following actions:

  • 创建一个路径并将一个矩形添加到该路径。Creates a path and adds a rectangle to the path.

  • 将该矩形绘制为黑色。Draws that rectangle to the screen in black.

  • 使用透视变形个 warp 路径。Warps the path with a perspective warp.

  • 用红色将扭曲矩形(路径)绘制到屏幕。Draws the warped rectangle (path) to the screen in red.

private:
   void WarpExample( PaintEventArgs^ e )
   {
      // Create a path and add a rectangle.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      RectangleF srcRect = RectangleF(0,0,100,200);
      myPath->AddRectangle( srcRect );

      // Draw the source path (rectangle)to the screen.
      e->Graphics->DrawPath( Pens::Black, myPath );

      // Create a destination for the warped rectangle.
      PointF point1 = PointF(200,200);
      PointF point2 = PointF(400,250);
      PointF point3 = PointF(220,400);
      array<PointF>^ destPoints = {point1,point2,point3};

      // Create a translation matrix.
      Matrix^ translateMatrix = gcnew Matrix;
      translateMatrix->Translate( 100, 0 );

      // Warp the source path (rectangle).
      myPath->Warp( destPoints, srcRect, translateMatrix, WarpMode::Perspective, 0.5f );

      // Draw the warped path (rectangle) to the screen.
      e->Graphics->DrawPath( gcnew Pen( Color::Red ), myPath );
   }
private void WarpExample(PaintEventArgs e)
{
             
    // Create a path and add a rectangle.
    GraphicsPath myPath = new GraphicsPath();
    RectangleF srcRect = new RectangleF(0, 0, 100, 200);
    myPath.AddRectangle(srcRect);
             
    // Draw the source path (rectangle)to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath);
             
    // Create a destination for the warped rectangle.
    PointF point1 = new PointF(200, 200);
    PointF point2 = new PointF(400, 250);
    PointF point3 = new PointF(220, 400);
    PointF[] destPoints = {point1, point2, point3};
             
    // Create a translation matrix.
    Matrix translateMatrix = new Matrix();
    translateMatrix.Translate(100, 0);
             
    // Warp the source path (rectangle).
    myPath.Warp(destPoints, srcRect, translateMatrix,
        WarpMode.Perspective, 0.5f);
             
    // Draw the warped path (rectangle) to the screen.
    e.Graphics.DrawPath(new Pen(Color.Red), myPath);
}
Public Sub WarpExample(ByVal e As PaintEventArgs)

    ' Create a path and add a rectangle.
    Dim myPath As New GraphicsPath
    Dim srcRect As New RectangleF(0, 0, 100, 200)
    myPath.AddRectangle(srcRect)

    ' Draw the source path (rectangle)to the screen.
    e.Graphics.DrawPath(Pens.Black, myPath)

    ' Create a destination for the warped rectangle.
    Dim point1 As New PointF(200, 200)
    Dim point2 As New PointF(400, 250)
    Dim point3 As New PointF(220, 400)
    Dim destPoints As PointF() = {point1, point2, point3}

    ' Create a translation matrix.
    Dim translateMatrix As New Matrix
    translateMatrix.Translate(100, 0)

    ' Warp the source path (rectangle).
    myPath.Warp(destPoints, srcRect, translateMatrix, _
    WarpMode.Perspective, 0.5F)

    ' Draw the warped path (rectangle) to the screen.
    e.Graphics.DrawPath(New Pen(Color.Red), myPath)
End Sub

适用于