Image:draw(x, y, [ ratio ], [ opacity ] ) method


Draws the Image on its Canvas, at the specified position

Parameters

x

A number representing the horizontal position (zero means the left side of the Canvas)

y

A number representing the vertical position (zero means the top side of the Canvas)

[ ratio ]

An optional number that represent a ratio to apply to to the Image width and height. The default value is 1, meaning that the original ratio will be used

[ opacity ]

An optional number representing the degree of opacity, defaulting to 1 (full opacity). A value of 0.5 means middle transparency

Return value

This function returns no value.

Example

local ui = require "ui" require "canvas" -- create a simple Window local win = ui.Window("Canvas.rect() sample", "fixed", 500, 400) -- create a Canvas local canvas = ui.Canvas(win) canvas.align = "all" canvas.bgcolor = 0x000000FF local w = canvas.width local h = canvas.height local img = canvas:Image("examples/canvas/LuaRT.png") function canvas:onPaint() img:draw(math.random(w)-80, math.random(h), math.random(), math.random()) end win:show() -- update user interface repeat ui.update() until not win.visible