lights FAQ Forum

2D Geometry
path2d WIP


2D geometry in Lua

local path = require'path'

Fast, full-featured 2D geometry library written in Lua.
Includes construction, drawing, measuring, hit testing and editing of 2D paths.


  • modular, bottom-up style programming (procedural, no state, no objects)
  • no dynamic allocations on most operations
  • all features available under affine transformation, with fast code paths for special cases
  • full support for SVG path command set and semantics and more.


See open issues.

Geometric types


  • bounding box
  • length at time t
  • point at time t
  • arc length parametrization (NYI)

Hit testing

  • shortest distance from point
  • inside/outside testing for closed subpaths (NYI)


  • simplification (decomposing into primitive operations)
  • adaptive interpolation of quad and cubic bezier curves
  • polygon offseting with different line join and line cap styles (NYI)
  • dash generation (NYI)
  • text-to-path (NYI)
  • conversion to cairo paths for drawing with cairo or with [sg_cairo]
  • conversion to OpenVG paths for drawing with the [openvg] API (NYI)


  • adding, removing and updating commands
  • splitting of lines, curves and arcs at time t
  • joining of lines, curves and arcs (NYI)
  • conversion between lines, curves, arcs and composite shapes (NYI).
  • direct manipulation [path editor][path2d_editor] with chained updates and constraints, making it easy to customize and extend to support new command types (WIP).

Last updated: 17 months ago | Edit on GitHub

Pkg type:other
Version: dev-38-g72a1fc6
Last commit:
License: Public Domain
Requires: none
Required by: none