Revisiting Coordinate Systems

Listing 7.19 gives a brief example of dealing with the Graphics.TranslateTransform() method. Internally, the TranslateTransform() method uses a Matrix class to represent the world transformation matrix used in calculating position, angle, and so on of where drawing occurs. A simple example of shifting where point [0, 0] on world coordinates appears on page coordinates is shown in Listing 7.21.

Listing 7.21. Shifting World Origin Using TranslateTransform()
1: procedure TWinForm.DrawBasicTransform(g: Graphics); 2: var 3: MyPen: Pen; 4: begin 5: MyPen := Pen.Create(Color.Black, 3); 6: g.DrawLine(MyPen, 50, 50, 300, 50); 7: g.DrawLine(MyPen, 50, 50, 50, 300); 8: 9: g.TranslateTransform(100, 100); 10: g.DrawLine(MyPen, ...

Get Delphi for .NET Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.