Graphics.TransformPoints 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
使用這個 Graphics 的目前全局和頁面轉換,將點陣列從一個座標空間轉換到另一個座標空間。
多載
TransformPoints(CoordinateSpace, CoordinateSpace, Point[]) |
使用這個 Graphics 的目前全局和頁面轉換,將點陣列從一個座標空間轉換到另一個座標空間。 |
TransformPoints(CoordinateSpace, CoordinateSpace, PointF[]) |
使用這個 Graphics 的目前全局和頁面轉換,將點陣列從一個座標空間轉換到另一個座標空間。 |
TransformPoints(CoordinateSpace, CoordinateSpace, Point[])
- 來源:
- 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 列舉的成員,指定來源座標空間。
範例
下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse
,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:
建立兩個點,並繪製兩個點之間的藍色線條。
設定世界轉換,以 x 方向的 40 數量和 30 的 Y 方向轉譯。
將世界轉換重設為身分識別。
在轉換點之間繪製紅色線條。
結果為藍色線條和其下方的轉譯紅色線條。
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 的目前全局和頁面轉換,將點陣列從一個座標空間轉換到另一個座標空間。
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 列舉的成員,指定來源座標空間。
範例
下列程式碼範例的設計目的是要與Windows Forms搭配使用,而且需要 PaintEventArgse
,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:
建立兩個點,並繪製兩個點之間的藍色線條。
設定世界轉換,以 x 方向的 40 數量和 30 的 Y 方向轉譯。
將世界轉換重設為身分識別,並在轉換點之間繪製紅線。
結果為藍色線條和其下方的轉譯紅色線條。
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
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應