2D Geometry
path2d
affine2d
box2d
clipper

# path2d_shapes

## local shapes = require’path2d_shapes’

Drawing and other math for 2D closed shapes. All construction routines take a `write` consumer function which will be called as: `write(command, args...)`.

## Stars and Regular Polygons

### `shapes.rpoly_to_lines(write, cx, cy, x1, y1, n)`

Construct a regular polygon with line segments. A regular polygon has a center, an anchor point and a number of segments.

### `shapes.star_to_star_2p(cx, cy, x1, y1, r2, n) -> cx, cy, x1, y1, x2, y2, n`

Convert a simple star to a 2-anchor-point star. A simple star has a center, an anchor point, a secondary radius and a number of leafs. A 2-anchor-point star has a center, two anchor points and a number of leafs.

### `shapes.star_to_lines(write, cx, cy, x1, y1, r2, n)`

Construct a star with line segments.

### `shapes.star_2p_to_lines(write, cx, cy, x1, y1, x2, y2, n)`

Construct a 2-anchor-point star using line segments.

## Formulas and the Superformula

### `shapes.formula_to_lines(write, formula, steps, ...)`

Linearly interpolate a shape defined by a custom formula, and unite the points with line segments.

### `shapes.superformula(t, cx, cy, size, a, b, m, n1, n2, n3)`

Return the point at time t (t covers the entire shape in the 0..1 range) on a superformula.

### `shapes.superformula_to_lines(write, cx, cy, size, steps, a, b, m, n1, n2, n3)`

Construct a superformula by linear interpolation using `steps` number of line segments.

Last updated: 7 years ago | Edit on GitHub

 Package: path2d Pkg type: Lua+ffi Version: 25f64fb Last commit: License: Public Domain Requires: more... Required by: more...

Top