GraphicsPath::Warp Method (array<PointF>^, RectangleF, Matrix^, WarpMode, Single)
Applies a warp transform, defined by a rectangle and a parallelogram, to this GraphicsPath.
Assembly: System.Drawing (in System.Drawing.dll)
public: void Warp( array<PointF>^ destPoints, RectangleF srcRect, Matrix^ matrix, WarpMode warpMode, float flatness )
Parameters
- destPoints
-
Type:
array<System.Drawing::PointF>^
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
-
Type:
System.Drawing::RectangleF
A RectangleF that represents the rectangle that is transformed to the parallelogram defined by destPoints.
- matrix
-
Type:
System.Drawing.Drawing2D::Matrix^
A Matrix that specifies a geometric transform to apply to the path.
- warpMode
-
Type:
System.Drawing.Drawing2D::WarpMode
A WarpMode enumeration that specifies whether this warp operation uses perspective or bilinear mode.
- flatness
-
Type:
System::Single
A value from 0 through 1 that specifies how flat the resulting path is. For more information, see the Flatten methods.
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.
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 ); }
Available since 1.1