Canvas:capture(file)method


Captures the current canvas content and saves it as a file on the disk.

Parameters

file

A File or a filename as a string.
The image format is determined by the file extension, which may be one of the following values : .bmp, .png, .jpg|.jpeg, .bmp, .tiff|.tif and .gif.

Return value

This function returns no value.

Example

--! luart-extensions import ui require "canvas" local win = ui.Window("Capture demo", 320, 130) local c = ui.Canvas(win) c.align = "all" function c:onPaint() self:begin() self:clear(0xFFFFFFFF) self:fillrect(10, 10, 310, 120, 0xFF0078D7) self:print("Hello LuaRT", 130, 60, 0xFFFFFFFF) self:flip() end win:show() -- wait 1s... sleep(1000) --.. then capture the canvas content c:capture("capture.png") -- keep window visible briefly then exit sleep(800)