Canvas.width read/write property


Get or set the Canvas area width. The width starts from 0 (left side of the Canvas) and increases to the right direction.

Example

local ui = require "ui" require "canvas" -- create a simple window local win = ui.Window("Canvas.height sample", 600, 400) local Canvas = ui.Canvas(win) Canvas.align = "all" function Canvas:onPaint() self:begin() self:clear() self:fillellipse(300,200, 50, 50, 0xdc4f2bff) self:flip() end -- Launch async Task for ui ui.run(win) -- Async Task to decrease Canvas height async(function() while win.visible do Canvas.width = Canvas.width - 5 if Canvas.width <= 0 then win:hide() sys.exit() end sleep() end end) -- wait for all tasks waitall()