Canvas.x read/write property
Get or set the Canvas horizontal position. The horizontal position start from 0 (left side of the parent widget) and increase to the right (right side of the parent widget).
Example
local ui = require "ui"
require "canvas"
-- create a simple window
local win = ui.Window("canvas.x sample", 600, 300)
local canvas = ui.Canvas(win, 0, 20)
ui.run(win)
async(function()
while win.visible and (canvas.x < 600) do
canvas.x = canvas.x + 2
canvas:begin()
canvas:clear(math.random(0xFFFFFFFF))
canvas:flip()
sleep()
win:status("x = "..canvas.x)
end
sys.exit()
end)
waitall()