Skip to main content
Version: 9.0.2

CANVAS:fill_rect

CANVAS:fill_rect(x1, y1, x2, y2, color)

Fill a rectangle defined by the bounding area of x1,y2 to x2,y2 with a specific color.

Parameters

ParameterTypeDescription
x1#numberThe x position of the first corner.
y1#numberThe y position of the first corner.
x2#numberThe x position of the second corner.
y2#numberThe y position of the second corner.
color#numberAn RGB color value as an integer value.

Example

-- Draw three colored bars across the canvas
function FillRGB(name)
local canvas = gre.get_canvas(name)
local size = canvas:get_dimensions()
local rw = size.width / 3
canvas:fill_rect(0, 0, rw, size.height, 0xff0000)
canvas:fill_rect(rw, 0, 2*rw, size.height, 0x00ff00)
canvas:fill_rect(2*rw, 0, 3*rw, size.height, 0x0000ff)
end