FANDOM


line( [x0,] [y0,] x1, y1, [col] )

Draws a line between two points.

x0
The x coordinate of the start of the line. If omitted, the x coordinate of the end of the previous line is used, or 0 if no previous line has been drawn.
y0
The y coordinate of the start of the line. If omitted, the y coordinate of the end of the previous line is used, or 0 if no previous line has been drawn.
x1
The x coordinate of the end of the line.
y1
The y coordinate of the end of the line.
col
The color of the line. If omitted, the color from the draw state is used. This also sets the color in the draw state.

Line continuation was added in PICO-8 0.1.12; if a line has already been drawn, you can omit the starting coordinates to continue the line from the ending coordinates of the previous line.

Examples Edit

-- draw a red diamond shape
line(63, 0, 126, 63, 8)
line(126, 63, 63, 126, 8)
line(63, 126, 0, 63, 8)
line(0, 63, 63, 0, 8)
 
-- draw the same red diamond shape
-- using line continuation
color(8)
line(63, 0, 126, 63)
line(63, 126)
line(0, 63)
line(63, 0)
 
-- draw 20 white lines in random locations
color(7)
for x=1,20 do
  line(rnd(128), rnd(128), rnd(128), rnd(128))
end
Line-example-1
Line-example-2

See also Edit

Community content is available under CC-BY-SA unless otherwise noted.