Поделиться через


Graphics.TransformPoints Метод

Определение

Преобразует массив точек из одного пространства координат в другое с помощью текущих преобразований мира и страниц этого Graphics.

Перегрузки

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

Преобразует массив точек из одного пространства координат в другое с помощью текущих преобразований мира и страниц этого Graphics.

TransformPoints(CoordinateSpace, CoordinateSpace, PointF[])

Преобразует массив точек из одного пространства координат в другое с помощью текущих преобразований мира и страниц этого Graphics.

TransformPoints(CoordinateSpace, CoordinateSpace, Point[])

Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
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 Forms и требует PaintEventArgse, который является параметром обработчика событий Paint. Код выполняет следующие действия:

  • Создает две точки и рисует синюю линию между ними.

  • Задает преобразование мира для перевода на сумму 40 в направлении x и 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[])

Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
Graphics.cs
Исходный код:
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 Forms и требует PaintEventArgse, который является параметром обработчика событий Paint. Код выполняет следующие действия:

  • Создает две точки и рисует синюю линию между ними.

  • Задает преобразование мира для перевода на сумму 40 в направлении x и 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

Применяется к