Skip to main content
A PathCommand represents a single drawing instruction inside a Path. Each command has a type, and a variable number of points depending on that type.

Fields

type

local path = Path.new()
path:moveTo(Vector.xy(0, 0))
path:lineTo(Vector.xy(10, 0))

for i, command in ipairs(path) do
  print(i, command.type)
end
-- 1 moveTo
-- 2 lineTo
See CommandType.

Methods

__len

The number of points varies depending on the command type:
  • moveTo: 1 point
  • lineTo: 1 point
  • quadTo: 2 points
  • cubicTo: 3 points
  • close: 0 points
local path = Path.new()
path:moveTo(Vector.xy(0, 0))
path:cubicTo(
  Vector.xy(25, -40),
  Vector.xy(75, 40),
  Vector.xy(100, 0)
)

local command = path[2]
print(command.type)      -- cubicTo
print(#command)          -- 3
Returns the number of points stored on this command.
local count = #command