Creates a new Path
that starts at startPoint
and is made up of the path commands,
parts
.
See also fromString
Readonly
bboxA rough estimate of the bounding box of the path. A slight overestimate. See getExactBBox
Readonly
partsThe individual shapes that make up this path.
Readonly
startLazy-loads and returns this path's geometry
Treats this as a closed path and returns true if part of rect
is roughly within
this path's interior.
Note: Assumes that this is a closed, non-self-intersecting path.
Optional
tolerance: numbertrue if all points on this are equivalent to the points on other
Returns a list of intersections with this path. If strokeRadius
is given,
intersections are approximated with the surface strokeRadius
away from this.
If strokeRadius > 0
, the resultant parameterValue
has no defined value.
Note: strokeRadius
is half of a stroke's width.
Optional
strokeRadius: numberthe nearest point on this path to the given point
.
Approximates this path with a group of line segments.
Like closedRoughlyIntersects except takes stroke width into account.
This is intended to be a very fast and rough approximation. Use intersection and signedDistance for more accurate (but much slower) intersection calculations.
Note: Unlike other methods, this accepts strokeWidth
(and not strokeRadius
).
strokeRadius
is half of strokeWidth
.
Returns the signed distance between point
and a curve strokeRadius
units
away from this path.
This returns the signed distance, which means that points inside this shape have their distance negated. For example,
import {Path, Vec2} from '@js-draw/math'; console.log(Path.fromString('m0,0 L100,0').signedDistance(Vec2.zero, 1));
would print -1
because (0,0) is on m0,0 L100,0
and thus one unit away from its boundary.
Note: strokeRadius = strokeWidth / 2
Returns a copy of this path with deleteFrom
until deleteUntil
replaced with insert
.
This method is analogous to Array.toSpliced.
Optional
options: PathSplitOptionsConvert to an SVG path representation.
If useNonAbsCommands
is given, relative path commands (e.g. l10,0
) are to be used instead of
absolute commands (e.g. L10,0
).
See also fromString.
Optional
useNonAbsCommands: booleanCreates a new path by joining [other] to the end of this path
allowReverse: true iff reversing other or this is permitted if it means no moveTo command is necessary when unioning the paths.
Optional
allowStatic
computeBBoxStatic
fromStatic
fromStatic
fromCreate a Path
from a subset of the SVG path specification.
Currently, this does not support elliptical arcs or s
and t
command
shorthands. See https://github.com/personalizedrefrigerator/js-draw/pull/19.
Static
toOptional
onlyAbsCommands: booleanTrue if we should avoid converting absolute coordinates to relative offsets -- such conversions can lead to smaller output strings, but also take time.
Represents a union of lines and curves.
To create a path from a string, see fromString.
Example