The backbuffer is where all drawing operations take place. The following method should be called once your drawing on the Canvas has been completed, so that your drawing can be displayed.
Canvas:flip() method
Flips the back buffer, displaying it on the Canvas.
Return value
This function returns no value.Example
local ui = require "ui"
require "canvas"
-- create a simple Window
local win = ui.Window("Canvas.flip() sample", "fixed", 320, 200)
-- create a Canvas
local canvas = ui.Canvas(win)
canvas.align = "all"
local x = 160
local y = 100
function win:onKey(key)
print("coucou")
if key == "VK_UP" then
y = y - 2
elseif key == "VK_DOWN" then
y = y + 2
elseif key == "VK_LEFT" then
x = x - 2
elseif key == "VK_RIGHT" then
x = x + 2
end
end
function canvas:onPaint()
self:clear()
self:fillcircle(x, y, 10, 0xA0D0A0)
self:flip()
end
win:show()
-- update user interface
repeat
ui.update()
until not win.visible