m (→See also: formatting) |
(line continuation) Tag: Visual edit |
||
Line 2: | Line 2: | ||
|name=line |
|name=line |
||
|shortdesc=Draws a line between two points. |
|shortdesc=Draws a line between two points. |
||
− | |x0||The x coordinate of the start of the line. |
+ | |x0|optional|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. |
+ | |y0|optional|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. |
|x1||The x coordinate of the end of the line. |
||
|y1||The y coordinate of the end of the line. |
|y1||The y coordinate of the end of the line. |
||
− | |col|optional|The color of the line. If omitted, the color from the [[DrawState|draw state]] is used. |
+ | |col|optional|The color of the line. If omitted, the color from the [[DrawState|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 == |
== Examples == |
||
Line 16: | Line 18: | ||
line(63, 126, 0, 63, 8) |
line(63, 126, 0, 63, 8) |
||
line(0, 63, 63, 0, 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 |
-- draw 20 white lines in random locations |
Revision as of 11:10, 16 April 2019
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
-- 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