Skip to main content
Version: 9.0.2

CANVAS:stroke_line

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

Stroke a line between the points x1,y1 to x2,y2 with a specific color. The width of the line is the last value passed to CANVAS:set_line_width or 1 if no width has ever been specified.

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

-- Stroke a triangle with three different colored line segments
function StrokeRGB(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

canvas:stroke_line(2, 2, mid, size.height, 0xff0000)
canvas:stroke_line(mid, size.height, size.width, 2, 0x00ff00)
canvas:stroke_line(2, 2, size.width, 2, 0x0000ff)
end