この Graphics オブジェクトの現在のワールド変換とページ変換を使用して、点の配列をある座標空間から別の座標空間に変換します。
Overloads Public Sub TransformPoints( _
ByVal destSpace As CoordinateSpace, _ ByVal srcSpace As CoordinateSpace, _ ByVal pts() As Point _)
[C#]
public void TransformPoints(CoordinateSpacedestSpace,CoordinateSpacesrcSpace,Point[] pts);
[C++]
public: void TransformPoints(CoordinateSpacedestSpace,CoordinateSpacesrcSpace,Pointpts[]);
[JScript]
public function TransformPoints(
destSpace : CoordinateSpace,srcSpace : CoordinateSpace,pts : Point[]);
パラメータ
- destSpace
変換先の座標空間を指定する CoordinateSpace 列挙体のメンバ。 - srcSpace
変換元の座標空間を指定する CoordinateSpace 列挙体のメンバ。 - pts
変換する点を表す Point 構造体の配列。
戻り値
このメソッドは値を返しません。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードは次のアクションを実行します。
- 2 つの点を作成し、その間に青の直線を描画します。
- x 方向に 40、y 方向に 30 平行移動するようにワールド変換を設定します。
- ワールド座標 (CoordinateSpace.World) の点をページ座標 (CoordinateSpace.Page) に変換します。
- ワールド変換を単位行列にリセットします。
- 変換された点の間に赤の直線を描画します。
[Visual Basic, C#] 青の直線と、その下に平行移動した赤の直線が生成されます。
Public Sub TransformPointsPoint(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
[C#]
public 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]);
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.TransformPoints オーバーロードの一覧