Graphics.TransformPoints 方法

定义

使用此 Graphics 的当前世界转换和页转换,将点数组从一个坐标空间转换到另一个坐标空间。

重载

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

使用此 Graphics 的当前世界转换和页转换,将点数组从一个坐标空间转换到另一个坐标空间。

TransformPoints(CoordinateSpace, CoordinateSpace, PointF[])

使用此 Graphics 的当前世界转换和页转换,将点数组从一个坐标空间转换到另一个坐标空间。

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

使用此 Graphics 的当前世界转换和页转换,将点数组从一个坐标空间转换到另一个坐标空间。

public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, cli::array <System::Drawing::Point> ^ pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.Point[] pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Point[] -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As Point())

参数

destSpace
CoordinateSpace

CoordinateSpace 枚举成员,它指定目标坐标空间。

srcSpace
CoordinateSpace

CoordinateSpace 枚举成员,它指定源坐标空间。

pts
Point[]

Point 结构数组,这些结构表示要转换的点。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建两个点并在它们之间绘制一条蓝线。

  • 将世界转换设置为在 x 方向按 40 和 30 在 y 方向的量进行平移。

  • 将点从) (World 世界坐标转换为页面坐标 (Page) 。

  • 将世界转换重置为标识。

  • 在转换的点之间绘制一条红线。

结果是一条蓝线,其下方是一条已转换的红线。

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 ] );
   }
private void TransformPointsPoint(PaintEventArgs e)
{

    // Create array of two points.
    Point[] points = { new Point(0, 0), new Point(100, 50) };

    // Draw line connecting two untransformed points.
    e.Graphics.DrawLine(new Pen(Color.Blue, 3), 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(new Pen(Color.Red, 3), points[0], points[1]);
}
Private Sub TransformPointsPoint(ByVal e As PaintEventArgs)

    ' Create array of two points.
    Dim points As Point() = {New Point(0, 0), New Point(100, 50)}

    ' Draw line connecting two untransformed points.
    e.Graphics.DrawLine(New Pen(Color.Blue, 3), 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(New Pen(Color.Red, 3), points(0), points(1))
End Sub

适用于

TransformPoints(CoordinateSpace, CoordinateSpace, PointF[])

Source:
Graphics.cs
Source:
Graphics.cs
Source:
Graphics.cs

使用此 Graphics 的当前世界转换和页转换,将点数组从一个坐标空间转换到另一个坐标空间。

public:
 void TransformPoints(System::Drawing::Drawing2D::CoordinateSpace destSpace, System::Drawing::Drawing2D::CoordinateSpace srcSpace, cli::array <System::Drawing::PointF> ^ pts);
public void TransformPoints (System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.PointF[] pts);
member this.TransformPoints : System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.Drawing2D.CoordinateSpace * System.Drawing.PointF[] -> unit
Public Sub TransformPoints (destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As PointF())

参数

destSpace
CoordinateSpace

CoordinateSpace 枚举成员,它指定目标坐标空间。

srcSpace
CoordinateSpace

CoordinateSpace 枚举成员,它指定源坐标空间。

pts
PointF[]

PointF 结构数组,这些结构表示要变换的点。

示例

下面的代码示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse,这是事件处理程序的参数Paint。 此代码执行以下操作:

  • 创建两个点并在它们之间绘制一条蓝线。

  • 将世界转换设置为在 x 方向按 40 和 30 在 y 方向的量进行平移。

  • 将点从) (World 世界坐标转换为页面坐标 (Page) 。

  • 将世界转换重置为标识,并在转换的点之间绘制一条红线。

结果是一条蓝线,其下方是一条已转换的红线。

public:
   void TransformPointsPointF( PaintEventArgs^ e )
   {
      // Create array of two points.
      array<PointF>^ points = {PointF(0.0F,0.0F),PointF(100.0F,50.0F)};

      // 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.0F, 30.0F );

      // 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 ] );
   }
private void TransformPointsPointF(PaintEventArgs e)
{

    // Create array of two points.
    PointF[] points = { new PointF(0.0F, 0.0F), new PointF(100.0F, 50.0F) };

    // Draw line connecting two untransformed points.
    e.Graphics.DrawLine(new Pen(Color.Blue, 3), points[0], points[1]);

    // Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40.0F, 30.0F);

    // 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(new Pen(Color.Red, 3), points[0], points[1]);
}
Private Sub TransformPointsPointF(ByVal e As PaintEventArgs)

    ' Create array of two points.
    Dim points As PointF() = {New PointF(0.0F, 0.0F), New PointF(100.0F, _
    50.0F)}

    ' Draw line connecting two untransformed points.
    e.Graphics.DrawLine(New Pen(Color.Blue, 3), points(0), points(1))

    ' Set world transformation of Graphics object to translate.
    e.Graphics.TranslateTransform(40.0F, 30.0F)

    ' 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(New Pen(Color.Red, 3), points(0), points(1))
End Sub

适用于