Graphics.Translate

From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!
Method

Graphics.Translate(translateX As Double, translateY As Double)

New in 2020r2

Supported for all project types and targets.

Translates the origin point by the specified translateX and translateY values. Useful with Rotate.

Notes

Support for Translate in Desktop and Console applications was added in 2021r1.

When used in combination with Rotate and/or Scale to draw into a PDFDocument, Translate may behave differently than it does when drawing to normal Graphics object because the translation is being handled by the PDF engine itself.

Sample Code

From within an MobileCanvas.Paint event handler:

// Rotate square in center of graphics area
Const Pi = 3.14159
g.Translate(g.Width / 2, g.Height / 2)
g.Rotate(Pi / 4) // 45 degrees or 1/8 of a circle
g.DrawingColor = Color.Blue
g.FillRectangle(10, 10, 50, 50)