Canvas:translate([ x, y ) method


Applyies a translation transformation on the Canvas

Canvas transformations are cumulative. Remember that the order of method calls (rotate(), translate()...) must be the opposite of the order of the desired transformation.

Parameters

x

A number representing the translation along the x-axis.

y

A number representing the translation along the y-axis.

Return value

This function returns no value.

Example

local ui = require "ui" require "canvas" local win = ui.Window("Canvas - Translation example", "fixed", 320, 240) local c = ui.Canvas(win) c.align = "all" local t = 0 -- Uses internal timer for 30fps drawing function c:onPaint() self:clear(0xffffffff) c:translate(t, 0) c:rect(0,0,50,50) t = t + 2 if t > 150 then t = -50 end end ui.run(win)