Image:drawrect(x, y, width, height, [ opacity ] ) method


Draws the Image on its Canvas, using the specified position, width, height and opacity.

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)

width

A number that represent the Image width

height

A number that represent the Image height

[ 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:drawrect(math.random(w), math.random(h), math.random(500), math.random(400), math.random(), math.random()) end win:show() -- update user interface repeat ui.update() until not win.visible