Graphics::TransformPoints Method (CoordinateSpace, CoordinateSpace, array<Point>^)
Transforms an array of points from one coordinate space to another using the current world and page transformations of this Graphics.
Assembly: System.Drawing (in System.Drawing.dll)
public: void TransformPoints( CoordinateSpace destSpace, CoordinateSpace srcSpace, array<Point>^ pts )
Parameters
- destSpace
-
Type:
System.Drawing.Drawing2D::CoordinateSpace
Member of the CoordinateSpace enumeration that specifies the destination coordinate space.
- srcSpace
-
Type:
System.Drawing.Drawing2D::CoordinateSpace
Member of the CoordinateSpace enumeration that specifies the source coordinate space.
- pts
-
Type:
array<System.Drawing::Point>^
Array of Point structures that represents the points to transformation.
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
Creates two points and draws a blue line between them.
Sets the world transform to translate by amounts 40 in the x direction and 30 in the y direction.
Transforms the points from world coordinates (World) to page coordinates (Page).
Resets the world transformation to the identity.
Draws a red line between the transformed points.
The result is a blue line and a translated red line below it.
public: void TransformPointsPoint( PaintEventArgs^ e ) { // Create array of two points. array<Point>^ points = {Point(0,0),Point(100,50)}; // Draw line connecting two untransformed points. e->Graphics->DrawLine( gcnew Pen( Color::Blue,3.0f ), points[ 0 ], points[ 1 ] ); // Set world transformation of Graphics object to translate. e->Graphics->TranslateTransform( 40, 30 ); // Transform points in array from world to page coordinates. e->Graphics->TransformPoints( CoordinateSpace::Page, CoordinateSpace::World, points ); // Reset world transformation. e->Graphics->ResetTransform(); // Draw line that connects transformed points. e->Graphics->DrawLine( gcnew Pen( Color::Red,3.0f ), points[ 0 ], points[ 1 ] ); }
Available since 1.1