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()
self:begin()
self:clear()
self:print("I'm a centered Canvas!", 10, 10)
self:flip()
end
-- update the user interface asynchronously until the user closes the Window
ui.run(win):wait()