Skip to main content

Path Util

make-subpath

make-subpath() 

Create a new subpath. A path is an array of subpaths.

origin:

Origin

segments:

Segments

closed:

Closed

first-subpath-closed

first-subpath-closed(
)

Get if the first subpath is closed

first-subpath-start

first-subpath-start(
)

Get the start position of the first path

subpath-start

subpath-start(
)

Get the start point of a subpath

subpath-end

subpath-end(
)

Get the end point of a subpath

last-subpath-end

last-subpath-end(
)

Get the end position of the last path

same-z-plane

same-z-plane() 

Tests whether every vertex in path lies on the same z-plane, returning (z, same-z) where z is the z-coordinate of the first vertex and same-z is true iff every other vertex is within tol of that z-coordinate.

path:

Input path; must be non-empty

Absolute z tolerance

bounds

bounds() 

Calculates the bounding points for a list of path segments

path:

Path

transform:

Transformation to apply on each coordinate

segment-lengths

segment-lengths() 

Returns an array of arrays with the lengths of all path segments. One sub-array for each subpath and its segments.

path:

Input path

samples:

auto or int

Number of samples to use for curves

length

length() 

Returns the sum of all segment lengths of a path.

segments:

Path segments

samples:

auto or int

Number of samples to take for curves

point-at

point-at() 

Get information about a point at a given distance on a path.

path:

The path

distance:

Distance along the path

reverse:

Travel from end to start

ignore-subpaths:

If false consider the whole path, including sub-paths

shorten-to

shorten-to() 

Shorten a path on one or both sides

path:

Path

distance:

Distance to shorten the path by

reverse:

If true, start from the end

Shortening mode for cubic segments

samples:

auto or int

Samples to take for measuring cubic segments

snap-to:

Optional array of points to try to move the shortened segment to

normalize

normalize() 

Normalize a path:

  • Add missing closing segments
  • Remove zero-length line segments

path:

Input path