Canvas:constructor(parent, [x], [y], [width], [height])constructor


The Canvas constructor returns a Canvas instance representing a drawing surface.

Parameters

parent

An object that will own the Canvas. Parent objects can be any of Window, Groupbox and TabItem

[x]

An optional number that indicates the Canvas horizontal position, in pixels. Zero means the left border of the parent.

[y]

An optional number that indicates the Canvas vertical position, in pixels. Zero means the top border of the parent.

[width]

An optional number that indicates the Canvas width in pixels, autosized to fit text content if omitted.

[height]

An optional number that indicates the Canvas height in pixels, autosized to fit text content if omitted.

Return value

The constructor returns a new Canvas instance.

Example

--! luart-extensions import ui require "canvas" -- create a simple Window local win = ui.Window("Canvas.enabled sample", 320, 200) local Canvas = ui.Canvas(win) Canvas.align = "all" function Canvas:onClick(x, y) ui.info("You have clicked on the Canvas at position "..x..", "..y) end win:show() -- update user interface repeat ui.update() until not win.visible