Canvas.align readwrite property


Get or set the Canvas alignment, which position and size will be aligned relative to its parent (alignment persists even if the size of the parent changes).

This property uses a string to specify the Canvas alignment :

  • "all" : the Canvas will be aligned along all the parent borders (and will cover the entire parent client area).
  • "bottom" : the Canvas will be aligned along the bottom border of the parent, preserving its height.
  • "top" : the Canvas will be aligned along the the top border of the parent, preserving its height.
  • "right" : the Canvas will be aligned along the right border of the parent, preserving its width.
  • "left" : the Canvas will be aligned along the left border of the parent, preserving its width.

Example

local ui = require "ui" require "canvas" -- create a fixed Window local win = ui.Window("Canvas:align() sample", "fixed", 320, 200) -- create a Canvas local canvas = ui.Canvas(win) -- align the Canvas in all of its parent area canvas.align = "all" -- set the onPaint() event handler to draw on the canvas function canvas:onPaint() canvas:clear() canvas:print("Hello World !", 10, 10) end -- shows the Window win:show() while win.visible do ui.update() end