Line
Description
The line()
function draws a straight line on the canvas between two points. The line color and width are determined by the current stroke settings.
Syntax
// Using positional parameters
line(x1, y1, x2, y2)
// Using named parameters
line(x1: Float, y1: Float, x2: Float, y2: Float)
Parameters
x1, y1
The coordinates of the line's start point
x2, y2
The coordinates of the line's end point
Example
// Draw a line from (100,100) to (200,200)
line(100, 100, 200, 200)
// Draw a horizontal line using named parameters
line(x1: 300, y1: 300, x2: 500, y2: 300)
Notes
- The line is drawn from (x1,y1) to (x2,y2)
- The stroke width is set to 3 by default
- The line color can be customized using the current stroke settings