Skip to main content
Version: 9.0.2

CANVAS:fill_poly

CANVAS:fill_poly(xytable, color)

Fill the content of a polygon through the points defined in the xytable with a specific color. The polygon must be a closed simple polygon.

Parameters

ParameterTypeDescription
xytable#tableA Lua table {{x=x1,y=y1},{x=x2,y=y2}...}. Alternatively two tables of parameters containing an array of points may be provided, as in {x1,x2,..}, {y1,y2,..} similar to gre.poly_string().
color#numberAn RGB color value as an integer value.

Example

-- Fill a triangle using a polygon
function FillRedTrianglePoly(name)
local canvas = gre.get_canvas(name)
local size = canvas:get_dimensions()
local mid = size.width / 2

-- Shrink the bounds to make the lines visible
size.height = size.height - 2
size.width = size.width - 2

local pts = {}
table.insert(pts, {x=2,y=2})
table.insert(pts, {x=mid,y=size.height})
table.insert(pts, {x=size.width,y=2})
table.insert(pts, pts[1]) --Close the polygon
canvas:fill_poly(pts, 0xff0000)
end