Canvas:fillrect(x0, y0, x1, y1, [ brush ] ) method
Draws a rectangle on the Canvas
Parameters
x0
A number representing the x coordinate of the upper left corner (zero means the left side of the Canvas)
y0
A number representing the y coordinate of the upper left corner (zero means the top side of the Canvas)
x1
A number representing the x coordinate of the lower right corner
y1
A number representing the y coordinate of the lower right corner
[ brush ]
An optional value that can represent any of the following values :
- A RGBA color, as an integer value
- LinearGradient : The line will be drawn with a colored linear gradient
- RadialGradient : The line will be drawn with a colored radial gradient
- Image : The line will be drawn with a picture pattern.
Return value
This function returns no value.Example
local ui = require "ui"
require "canvas"
-- create a simple Window
local win = ui.Window("Canvas.fillrect() 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
function canvas:onPaint()
self:begin()
self:fillrect(math.random(w), math.random(w), math.random(h), math.random(h), math.random(0xFFFFFFFF))
self:flip()
end
ui.run(win):wait()