GraphicsPath.Warp Method
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath object.
Overload List
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath object.
[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF)
[C#] public void Warp(PointF[], RectangleF);
[C++] public: void Warp(PointF[], RectangleF);
[JScript] public function Warp(PointF[], RectangleF);
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath object.
[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix)
[C#] public void Warp(PointF[], RectangleF, Matrix);
[C++] public: void Warp(PointF[], RectangleF, Matrix*);
[JScript] public function Warp(PointF[], RectangleF, Matrix);
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath object.
[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix, WarpMode)
[C#] public void Warp(PointF[], RectangleF, Matrix, WarpMode);
[C++] public: void Warp(PointF[], RectangleF, Matrix*, WarpMode);
[JScript] public function Warp(PointF[], RectangleF, Matrix, WarpMode);
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath object.
[Visual Basic] Overloads Public Sub Warp(PointF(), RectangleF, Matrix, WarpMode, Single)
[C#] public void Warp(PointF[], RectangleF, Matrix, WarpMode, float);
[C++] public: void Warp(PointF[], RectangleF, Matrix*, WarpMode, float);
[JScript] public function Warp(PointF[], RectangleF, Matrix, WarpMode, float);
Example
[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, 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.
- Warps the path with a perspective warp.
- Draws the warped rectangle (path) to the screen in red.
[Visual Basic, C#] Note This example shows how to use one of the overloaded versions of Warp. For other examples that might be available, see the individual overload topics.
[Visual Basic] Public Sub WarpExample(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 [C#] 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); }
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
See Also
GraphicsPath Class | GraphicsPath Members | System.Drawing.Drawing2D Namespace