Canvas:translate(x, y)method
Applyies a translation transformation on the Canvas
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
--! luart-extensions
import 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
await win:showasync()