Canvas:center() method
Centers the Canvas on the parent widget.
Return value
This function returns no value.Example
local ui = require "ui"
require "canvas"
-- create a simple Window
local win = ui.Window("Canvas:center() sample", 640, 480)
-- create a canvas and center it
local canvas = ui.Canvas(win, 0, 0, 600, 400)
canvas:center()
-- set the onPaint() event handler to draw on the canvas
function canvas:onPaint()
canvas:clear()
canvas:print("I'm a centered Canvas!", 10, 10)
end
win:show()
-- update the user interface until the user closes the Window
repeat
ui.update()
until not win.visible