Line to

From Sim Innovations Wiki
Jump to navigation Jump to search

Description

_line_to(x, y)

_line_to is used to draw a line from the pen location to the new location provided in the arguments.

Info This function may only be called within a canvas draw callback

Return value

This function won't return any value.

Arguments

# Argument Type Description
1 x Number This is the left pixel of the canvas where the end of your line should be.
2 y Number This is the top pixel of the canvas where the end of your line should be.

Example

canvas_id = canvas_add(0, 0, 200, 200)

canvas_draw(canvas_id, function()
  -- Queue a line from 100,100 through multiple points
  _move_to(100, 100)
  _line_to(150, 150)
  _line_to(100, 180)
  _line_to(50, 100)
  
  -- Stroke the line (line width 6)
  _stroke("red", 6)
end)
Output of code above