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 function c:onPaint() self:begin() self:clear(0xffffffff) self:identity() self:translate(t, 0) self:fillrect(0, 90,50,140, 0x52BE80FF) t = t + 2 if t > 300 then t = -50 end self:flip() end ui.run(win):wait()