@baku89/pave / Path
Path
Functions for manipulating paths represented as Path.
For creating new paths, see Primitives. Getting intrinsic properties of paths, see Properties. Manipulating existing paths, such as transforming, styling, deforming, etc., see Modifiers.
Inputs are never mutated; returned paths are new objects unless noted otherwise.
Primitives
arc()
arc(
center,radius,startAngle,endAngle,options):Path
Defined in: Path.ts:111
Creates an arc path.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the arc |
radius | number | The radius of the arc |
startAngle | number | The start angle in radians |
endAngle | number | The end angle in radians |
options | ArcOptions | - |
Returns
The newly created path
Example
arcByPoints()
arcByPoints(
start,through,end):Path
Defined in: Path.ts:112
Creates an arc path from the given three points. If the points are collinear, it will create a straight line path.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The start point |
through | vec2 | The point that the arc passes through |
end | vec2 | The end point |
Returns
The newly created path
arcByPointsAngle()
arcByPointsAngle(
start,end,angle):Path
Defined in: Path.ts:114
Creates an arc path from two points and an angle.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The start point |
end | vec2 | The end point |
angle | number | The angle of arc in degrees. If the angle is positive, the arc will be drawn in the sweep direction (clockwise in Y-down coordinate system). |
Returns
The newly created path
arcByPointsTangent()
arcByPointsTangent(
start,startTangent,end):Path
Defined in: Path.ts:113
Creates an arc path from start point, start tangent, and end point.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The start point |
startTangent | vec2 | The tangent at the start point |
end | vec2 | The end point |
Returns
A newly created open arc path
circle()
circle(
center,radius):Path
Defined in: Path.ts:105
Creates a circle path from the given center and radius.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the circle |
radius | number | The radius of the circle |
Returns
The newly created path
Example
cubicBezier()
cubicBezier(
start,control1,control2,point):Path
Defined in: Path.ts:123
Creates a path consisting of a single C command.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The start point |
control1 | vec2 | The first control point |
control2 | vec2 | The second control point |
point | vec2 | The end point |
Returns
The newly created path
dot()
dot(
point):PathL
Defined in: Path.ts:117
Creates a “dot“ path, which consists of only a M command to the specified point followed by Z command. This will be rendered only if the lineCap of the drawing context is set to 'round' or 'square'.
Parameters
| Parameter | Type | Description |
|---|---|---|
point | vec2 | The center point of the dot |
Returns
The newly created paths
Example
ellipse()
ellipse(
center,radius):Path
Defined in: Path.ts:110
Creates an ellipse path from the given center and radius.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the ellipse |
radius | vec2 | The radius of the ellipse |
Returns
The newly created path
Example
fan()
fan(
center,innerRadius,outerRadius,startAngle,endAngle):Path
Defined in: Path.ts:115
Creates a fan path.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the fan |
innerRadius | number | The inner radius of the fan |
outerRadius | number | The outer radius of the fan |
startAngle | number | The start angle in radians |
endAngle | number | The end angle in radians |
Returns
The newly created path
Example
fromSegment()
fromSegment(
segment):Path
Defined in: Path.ts:128
Creates an open path consist of only a single command.
Parameters
| Parameter | Type | Description |
|---|---|---|
segment | Segment | The segment to create |
Returns
The newly created path
grid()
grid(
rect,divs):PathL
Defined in: Path.ts:122
Parameters
| Parameter | Type |
|---|---|
rect | Rect |
divs | vec2 |
Returns
halfLine()
halfLine(
point,through,distance):Path
Defined in: Path.ts:108
Creates a half-line, infinite line in one direction from a starting point and a point that the line passes through. It is not actually an inifinite, but one with a very large length.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
point | vec2 | undefined | The starting point |
through | vec2 | undefined | The point that the line passes through |
distance | number | 1e8 | The length of the half-line |
Returns
The half-line path
infiniteLine()
infiniteLine(
point0,point1,distance):Path
Defined in: Path.ts:107
Creates an infinite line path from the given two points. Unlike line, the line will be drawn nearly infinitely in both directions.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
point0 | vec2 | undefined | The first point |
point1 | vec2 | undefined | The second point |
distance | number | 1e8 | The length of the infinite line for each direction |
Returns
The infinite line path
line()
line(
start,end):PathL
Defined in: Path.ts:116
Creates a linear path from two points describing a line.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The line’s starting point |
end | vec2 | The line’s ending point |
Returns
The newly created path
Example
nBezier()
nBezier(
points):Path
Defined in: Path.ts:125
Create a path consisting of cubic Bézier curves approximating the arbitrary higher-order Bézier curve.
Parameters
| Parameter | Type | Description |
|---|---|---|
points | vec2[] | The control points of the Bézier curve |
Returns
The newly created path
ngon()
ngon(
center,radius,sides):PathL
Defined in: Path.ts:121
Creates a regular polygon. The first vertex will be placed at the +X axis relative to the center.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the polygon |
radius | number | The radius of the circumcircle of the polygon |
sides | number | The number o sides of the polygon |
Returns
The newly created path
Example
polygon()
polygon(…
points):PathL
Defined in: Path.ts:119
Creates a closed polyline from the given points.
Parameters
| Parameter | Type | Description |
|---|---|---|
…points | vec2[] | The points describing the polygon |
Returns
The newly created path
Example
quadraticBezier()
quadraticBezier(
start,control,point):Path
Defined in: Path.ts:124
Creates a quadratic Bézier curve path from the given points.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The start point |
control | vec2 | The control point |
point | vec2 | The end point |
Returns
THe newly created path
rect()
rect(
start,end):Path
Defined in: Path.ts:102
Creates a rectangle path from the given two points.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The first point defining the rectangle |
end | vec2 | The second point defining the rectangle |
Returns
The newly created path
Example
rectangle()
rectangle(
start,end):Path
Defined in: Path.ts:101
Creates a rectangle path from the given two points.
Parameters
| Parameter | Type | Description |
|---|---|---|
start | vec2 | The first point defining the rectangle |
end | vec2 | The second point defining the rectangle |
Returns
The newly created path
Example
rectFromCenter()
rectFromCenter(
center,size):Path
Defined in: Path.ts:103
Creates a rectangle path from the given center and size.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the rectangle |
size | vec2 | The size of the rectangle |
Returns
The newly created path
regularPolygon()
regularPolygon(
center,radius,sides):PathL
Defined in: Path.ts:120
Creates a regular polygon. The first vertex will be placed at the +X axis relative to the center.
Parameters
| Parameter | Type | Description |
|---|---|---|
center | vec2 | The center of the polygon |
radius | number | The radius of the circumcircle of the polygon |
sides | number | The number o sides of the polygon |
Returns
The newly created path
Example
roundRect()
roundRect(
start,end,radii):Path
Defined in: Path.ts:104
Creates a rounded rectangle. The arguments are almost the same as the CanvasRenderingContext2D’s roundRect method.
Parameters
| Parameter | Type |
|---|---|
start | vec2 |
end | vec2 |
radii | number | [number] | [number, number] | [number, number, number] | [number, number, number, number] |
Returns
See
https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect
semicircle()
semicircle(
start,end,closed):Path
Defined in: Path.ts:106
Creates a semicircle path from the given start and end points.
Parameters
| Parameter | Type | Default value |
|---|---|---|
start | vec2 | undefined |
end | vec2 | undefined |
closed | boolean | true |
Returns
Properties
derivative()
derivative(
path,loc):vec2
Defined in: Path.ts:141
Calculates the normalized tangent vector of the path at the given location.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to calcuate |
loc | PathLocation | The location on the path |
Returns
vec2
The tangent vector
normal()
normal(
path,loc):vec2
Defined in: Path.ts:143
Calculates the normalized tangent vector of the path at the given location.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to calcuate |
loc | PathLocation | The location on the path |
Returns
vec2
The tangent vector
orientation()
orientation(
path,loc):mat2d
Defined in: Path.ts:144
Calculates the transformation matrix of the path at the given location. The x-axis of the matrix is the tangent vector and the y-axis is the normal vector, and the translation is the point on the path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to calculate |
loc | PathLocation | The location on the path |
Returns
mat2d
The transformation matrix at the given offset
point()
point(
path,loc):vec2
Defined in: Path.ts:140
Calculates the position on the path at the given location.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to calculate |
loc | PathLocation | The location on the path |
Returns
vec2
The position at the given offset
segment()
segment(
path,curveIndex,segmentIndex?):Segment
Defined in: Path.ts:136
Returns the segment of the path by indices. If the segmentIndex is omitted, the curveIndex is treated as the linear segment index of the whole path. It also supports negative indices, which count from the end of the path or curve.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path that contains the segment |
curveIndex | number | The index of the curve. |
segmentIndex? | number | The index of the segment in the curve. |
Returns
The segment
tangent()
tangent(
path,loc):vec2
Defined in: Path.ts:142
Calculates the normalized tangent vector of the path at the given location.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to calcuate |
loc | PathLocation | The location on the path |
Returns
vec2
The tangent vector
Modifiers
chamfer()
chamfer(
path,distance):Path
Defined in: Path.ts:163
Chamfers the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to chamfer |
distance | number | The distance of chamfer |
Returns
The newly created path
distort()
Defined in: Path.ts:162
Distorts path by the given transformation function. It assumes that the continuity of transformation is smooth in the spatial domain and has no singularities or cusps.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to distort |
transform | (position) => mat2d | The distort function that maps a point coordinate to a transformation matrix. The translation component is absolute, and affects points of Bézier curves. The rotation, scaling, and skewing components affect the orientation of two handles. |
__namedParameters | DistortOptions | - |
Returns
The newly created path
Example
fillet()
fillet(
path,radius):Path
Defined in: Path.ts:164
Fillets the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to fillet |
radius | number | The radius of fillet |
Returns
The newly created path
flatten()
flatten(
path,flatness):Path
Defined in: Path.ts:158
Flattens the curves in path to straight lines (recursive midpoint split until chord / hull deviation ≤ flatness).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | The path to flatten |
flatness | number | 0.25 | The maximum distance between the path and the flattened path |
Returns
The flattened path consists of only M, L, and Z commands
Example
join()
join(
paths):Path
Defined in: Path.ts:157
Joins the given paths into a single open paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
paths | Path[] | The paths to join |
Returns
The joined path
merge()
merge(
pathOrCurves):Path
Defined in: Path.ts:129
Merges the given paths into a single path. Unlike join or unite, the vertices are not connected, and it simply returns compound path.
Parameters
| Parameter | Type |
|---|---|
pathOrCurves | (Path | Curve)[] |
Returns
offset()
offset(
path,offset,options?):Path
Defined in: Path.ts:155
Creates an offset path from the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to offset |
offset | number | The width of offset |
options? | OffsetOptions | The options |
Returns
The newly created path
Example
offsetStroke()
offsetStroke(
path,width,options?):Path
Defined in: Path.ts:156
Creates an offset path from the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to offset |
width | number | The width of stroke |
options? | OffsetStrokeOptions | The options |
Returns
The newly created path
Example
reduce()
reduce(
path,options):Path
Defined in: Path.ts:189
Cleans up the path by removing redundant vertices and
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | |
options | ReduceOptions | - |
Returns
reverse()
reverse(
path,options:):Path
Defined in: Path.ts:150
Reverses the given path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to reverse |
options: | ReverseOptions | The options |
Returns
The reversed path
spawn()
spawn(
path,fn,__namedParameters):Path
Defined in: Path.ts:148
Maps each segments in the path to a path and create a new path concatinating those paths.
Parameters
| Parameter | Type |
|---|---|
path | Path |
fn | (seg, segmentIndex, curve) => Path |
__namedParameters | SpawnOptions |
Returns
spawnCurve()
spawnCurve<
V1,V2>(path,fn):Path<V2>
Defined in: Path.ts:147
Maps each curves in the path to a single or array of curves and creates a new path concatinating those curves. Unlike spawnVertex, you can also change the number of curves, or open/close state of the curves.
Type Parameters
| Type Parameter | Default type |
|---|---|
V1 extends Vertex | Vertex |
V2 extends Vertex | Vertex |
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path<V1> | The path to map |
fn | (curve, curveIndex) => Curve<V2> | Curve<V2>[] | The curve mapping function. |
Returns
Path<V2>
The newly created path
split()
split(
path,locs):Path[]
Defined in: Path.ts:161
Splits the path into multiple paths at the given locations.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to split |
locs | Iterable<PathLocation> | The locations to split |
Returns
Path[]
The splitted paths
subdiv()
subdiv(
path,division):Path
Defined in: Path.ts:160
Subdivides each segment in the path into specific number of sub-segments.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to subdivide |
division | number | The number of division for each segment |
Returns
The newly created path
subdivide()
subdivide(
path,division):Path
Defined in: Path.ts:159
Subdivides each segment in the path into specific number of sub-segments.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to subdivide |
division | number | The number of division for each segment |
Returns
The newly created path
toC()
toC(
path,unarcAngle):PathC
Defined in: Path.ts:154
Converts all commands in the path to cubic Bézier curve commands.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | The path to convert |
unarcAngle | number | 90 | The angle step for approximating arc commands with cubic Béziers |
Returns
The new path with only cubic Bézier curve commands
toCubicBezier()
toCubicBezier(
path,unarcAngle):PathC
Defined in: Path.ts:153
Converts all commands in the path to cubic Bézier curve commands.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | The path to convert |
unarcAngle | number | 90 | The angle step for approximating arc commands with cubic Béziers |
Returns
The new path with only cubic Bézier curve commands
transform()
transform(
path,matrix):Path
Defined in: Path.ts:149
Transforms the given path by the given matrix.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to transform |
matrix | mat2d | The matrix to transform the path by |
Returns
The transformed path
trim()
trim(
path,from,to,crossFirstPoint):Path
Defined in: Path.ts:151
Trims the path from the given location to the given location.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | The path to trim |
from | PathLocation | undefined | The start location |
to | PathLocation | undefined | The end location |
crossFirstPoint | boolean | true | - |
Returns
The trimmed path
unarc()
unarc(
path,angle):UnarcPath
Defined in: Path.ts:152
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | |
angle | number | 90 |
Returns
Example
Boolean Operations
subtract()
subtract(
subject,tools):Path
Defined in: Path.ts:167
Subtracts the tools from the subject.
Parameters
| Parameter | Type | Description |
|---|---|---|
subject | Path | The target path to be subtracted |
tools | Path[] | The paths to subtract |
Returns
The resulting path
unite()
unite(
paths):Path
Defined in: Path.ts:166
Unites the given paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
paths | Path[] | The paths to unite |
Returns
The resulting path
Converters
drawToCanvas()
drawToCanvas(
path,context):void
Defined in: Path.ts:176
Draws the given path to the context. It calls context.beginPath at the beginning, so please note that the sub-paths already stacked on the context are also cleared. Note that you also need to call context.stroke or context.fill to actually draw the path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to draw |
context | CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D | The Canvas context |
Returns
void
drawToP5()
drawToP5(
path,p5Instance):void
Defined in: Path.ts:177
Draws the given path to the context. It calls beginShape at the beginning, drawing the path with vertex and bezierVertex commands, then calls endShape at the end if the curve is closed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
path | Path | undefined | The path to draw |
p5Instance | __module | Window | window | The p5.js instance. Pass the instance only if you are using p5.js in instance mode. |
Returns
void
fromD()
fromD(
d):Path
Defined in: Path.ts:170
Parses the given d attribute of an SVG path and creates a new path. Internally uses svgpath library.
Parameters
| Parameter | Type | Description |
|---|---|---|
d | string | The d attribute of an SVG path |
Returns
The newly created path
fromSVG()
fromSVG(
commands):Path
Defined in: Path.ts:173
Converts an array of SVG commands to a Path.
Parameters
| Parameter | Type | Description |
|---|---|---|
commands | SVGCommand[] | The array of SVG commands |
Returns
The newly created path
fromSVGString()
fromSVGString(
d):Path
Defined in: Path.ts:169
Parses the given d attribute of an SVG path and creates a new path. Internally uses svgpath library.
Parameters
| Parameter | Type | Description |
|---|---|---|
d | string | The d attribute of an SVG path |
Returns
The newly created path
toD()
toD(
path):string
Defined in: Path.ts:172
Converts the given path to a string that can be used as the d attribute of an SVG path element.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to convert |
Returns
string
The string for the d attribute of the SVG path element
toPaperPath()
toPaperPath(
path):Path|CompoundPath
Defined in: Path.ts:179
Converts the given path to paper.Path
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to convert |
Returns
Path | CompoundPath
The newly created paper.Path instance
See
http://paperjs.org/reference/pathitem/
toSVGString()
toSVGString(
path):string
Defined in: Path.ts:171
Converts the given path to a string that can be used as the d attribute of an SVG path element.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to convert |
Returns
string
The string for the d attribute of the SVG path element
Draw Functions
addVertex()
addVertex(
path,vertex):Path
Defined in: Path.ts:183
Appends the given command to the end of the path.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The base path |
vertex | Vertex | The vertex to append |
Returns
The newely created path
arcTo()
arcTo(
path,radii,xAxisRotation,largeArcFlag,sweepFlag,point):Path
Defined in: Path.ts:187
Returns the new path with the new A (arc) command at the end.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The base path |
radii | vec2 | The radii of the ellipse used to draw the arc |
xAxisRotation | number | The rotation angle of the ellipse’s x-axis relative to the x-axis of the current coordinate system, expressed in degrees |
largeArcFlag | boolean | The large arc flag. If true, then draw the arc spanning greather than 180 degrees. Otherwise, draw the arc spanning less than 180 degrees. |
sweepFlag | boolean | The sweep flag. If true, then draw the arc in a “positive-angle” direction in the current coordinate system. Otherwise, draw it in a “negative-angle” direction. |
point | vec2 | The end point of the arc |
Returns
The newely created path
cubicBezierTo()
cubicBezierTo(
path,control1,control2,point):Path
Defined in: Path.ts:185
Returns the new path with the new C (cubic Bézier curve) command at the end.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The base path |
control1 | vec2 | The first control point |
control2 | vec2 | The second control point |
point | vec2 | The end point |
Returns
The newely created path
lineTo()
lineTo(
path,point):Path
Defined in: Path.ts:184
Returns the new path with the new L (line-to) command at the end.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The base path |
point | vec2 | The point to draw a line to |
Returns
The newely created path
pen()
pen():
Pen
Defined in: Path.ts:190
Creates a new Path instance to begin drawing a path.
Returns
Pen
quadraticBezierTo()
quadraticBezierTo(
path,control,point):Path
Defined in: Path.ts:186
Returns the new path with the new Q (quadratic Bézier curve) command at the end.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The base path |
control | vec2 | The control point |
point | vec2 | The end point |
Returns
The newely created path
Utilities
toTime()
toTime(
path,location):Required<TimePathLocation> &object
Defined in: Path.ts:138
Retrieves the segment location information from the given path and path-based signed location.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | Path | The path to retrieve the segment location |
location | PathLocation | The path-based location |
Returns
Required<TimePathLocation> & object
The information of the segment location
unlinearSegmentIndex()
unlinearSegmentIndex(
path,linearSegmentIndex):object
Defined in: Path.ts:139
Converts a signed linear segment index to a pair of curve and unsgined segment index.
Parameters
| Parameter | Type |
|---|---|
path | Path |
linearSegmentIndex | number |
Returns
object
| Name | Type |
|---|---|
curveIndex | number |
segmentIndex | number |
Other
ArcOptions
ArcOptions:
NT_ArcOptions
Defined in: Path.ts:89
area()
area(
arg):number
Defined in: Path.ts:133
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
number
bounds()
bounds(
arg):Rect
Defined in: Path.ts:132
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
Rect
circleFromPoints()
circleFromPoints(
p1,p2?,p3?,__namedParameters?):Path
Defined in: Path.ts:109
Parameters
| Parameter | Type |
|---|---|
p1 | vec2 |
p2? | null | vec2 |
p3? | null | vec2 |
__namedParameters? | CircleFromPointsOptions |
Returns
CircleFromPointsOptions
CircleFromPointsOptions:
NT_CircleFromPointsOptions
Defined in: Path.ts:90
close()
close(
path,__namedParameters):Path
Defined in: Path.ts:188
Parameters
| Parameter | Type |
|---|---|
path | Path |
__namedParameters | PathCloseOptions |
Returns
DistortOptions
DistortOptions:
NT_DistortOptions
Defined in: Path.ts:91
empty
constempty:Path=PPrimitives.empty
Defined in: Path.ts:100
formula()
formula(
f,iter,__namedParameters):Path
Defined in: Path.ts:126
Parameters
| Parameter | Type |
|---|---|
f | (t) => vec2 |
iter | Iterable<number> |
__namedParameters | FormulaOptions |
Returns
FormulaOptions
FormulaOptions:
NT_FormulaOptions
Defined in: Path.ts:92
fromPaperPath()
fromPaperPath(
arg):Path
Defined in: Path.ts:180
Parameters
| Parameter | Type |
|---|---|
arg | PathItem |
Returns
length()
length(
arg):number
Defined in: Path.ts:131
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
number
moveTo()
moveTo(
path,point):Path
Defined in: Path.ts:182
Parameters
| Parameter | Type |
|---|---|
path | Path |
point | vec2 |
Returns
OffsetOptions
OffsetOptions:
NT_OffsetOptions
Defined in: Path.ts:93
OffsetStrokeOptions
OffsetStrokeOptions:
NT_OffsetStrokeOptions
Defined in: Path.ts:94
PathCloseOptions
PathCloseOptions:
NT_PathCloseOptions
Defined in: Path.ts:95
Pen
constPen: typeofPen=PDraw.Pen
Defined in: Path.ts:191
polyline()
polyline(…
points):PathL
Defined in: Path.ts:118
Parameters
| Parameter | Type |
|---|---|
…points | vec2[] |
Returns
ReduceOptions
ReduceOptions:
NT_ReduceOptions
Defined in: Path.ts:96
ReverseOptions
ReverseOptions:
NT_ReverseOptions
Defined in: Path.ts:97
segmentCount()
segmentCount(
arg):number
Defined in: Path.ts:134
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
number
segments()
segments(
arg):Segment[]
Defined in: Path.ts:135
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
Segment[]
SpawnOptions
SpawnOptions:
NT_SpawnOptions
Defined in: Path.ts:98
spawnVertex()
spawnVertex<
V1,V2>(path,fn):Path<V2>
Defined in: Path.ts:146
Type Parameters
| Type Parameter | Default type |
|---|---|
V1 extends Vertex | Vertex |
V2 extends Vertex | Vertex |
Parameters
| Parameter | Type |
|---|---|
path | Path<V1> |
fn | (segment, segmentIndex, curve) => V2 | V2[] |
Returns
Path<V2>
toPath2D()
toPath2D(
arg):Path2D
Defined in: Path.ts:175
Parameters
| Parameter | Type |
|---|---|
arg | Path |
Returns
Path2D