PavePave
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
Home
Guide
API
Sandbox
  • English
  • 日本語
GitHub
  • Path

@baku89/pave v0.7.1


@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.

Primitives

arc()

arc(center, radius, startAngle, endAngle, options): Path

Defined in: Path.ts:533

Creates an arc path.

Parameters

ParameterTypeDescription
centervec2The center of the arc
radiusnumberThe radius of the arc
startAnglenumberThe start angle in radians
endAnglenumberThe end angle in radians
optionsArcOptions-

Returns

Path

The newly created path

Example


arcByPoints()

arcByPoints(start, through, end): Path

Defined in: Path.ts:580

Creates an arc path from the given three points. If the points are collinear, it will create a straight line path.

Parameters

ParameterTypeDescription
startvec2The start point
throughvec2The point that the arc passes through
endvec2The end point

Returns

Path

The newly created path


arcByPointsAngle()

arcByPointsAngle(start, end, angle): Path<Vertex>

Defined in: Path.ts:686

Creates an arc path from two points and an angle.

Parameters

ParameterTypeDescription
startvec2The start point
endvec2The end point
anglenumberThe 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

Path<Vertex>

The newly created path


arcByPointsTangent()

arcByPointsTangent(start, startTangent, end): Path

Defined in: Path.ts:651

Creates an arc path from start point, start tangent, and end point.

Parameters

ParameterTypeDescription
startvec2The start point
startTangentvec2The tangent at the start point
endvec2The end point

Returns

Path

A newly created open arc path


circle()

circle(center, radius): Path

Defined in: Path.ts:295

Creates a circle path from the given center and radius.

Parameters

ParameterTypeDescription
centervec2The center of the circle
radiusnumberThe radius of the circle

Returns

Path

The newly created path

Example


circleFromPoints()

circleFromPoints(p1, p2?, p3?, __namedParameters?): Path

Defined in: Path.ts:376

Creates a circle path which passes through the given points.

Parameters

ParameterTypeDescription
p1vec2The first point
p2?null | vec2The second point
p3?null | vec2The third point
__namedParameters?CircleFromPointsOptions-

Returns

Path

The circle path, whose first point matches to p1. After duplicating points are removed, if there are only one point, creates a circle with zero radius. For two points, creates a circle from the two points as the diameter. Otherwise, creates a circle that passes through the three points.

Example


cubicBezier()

cubicBezier(start, control1, control2, point): Path

Defined in: Path.ts:933

Creates a path consisting of a single C command.

Parameters

ParameterTypeDescription
startvec2The start point
control1vec2The first control point
control2vec2The second control point
pointvec2The end point

Returns

Path

The newly created path


dot()

dot(point): PathL

Defined in: Path.ts:800

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

ParameterTypeDescription
pointvec2The center point of the dot

Returns

PathL

The newly created paths

Example


ellipse()

ellipse(center, radius): Path

Defined in: Path.ts:473

Creates an ellipse path from the given center and radius.

Parameters

ParameterTypeDescription
centervec2The center of the ellipse
radiusvec2The radius of the ellipse

Returns

Path

The newly created path

Example


empty

const empty: Path

Defined in: Path.ts:161

Empty path.


fan()

fan(center, innerRadius, outerRadius, startAngle, endAngle): Path

Defined in: Path.ts:750

Creates a fan path.

Parameters

ParameterTypeDescription
centervec2The center of the fan
innerRadiusnumberThe inner radius of the fan
outerRadiusnumberThe outer radius of the fan
startAnglenumberThe start angle in radians
endAnglenumberThe end angle in radians

Returns

Path

The newly created path

Example


formula()

formula(f, iter, options): Path

Defined in: Path.ts:1073

Creates a path from the given formula, which maps a parameter t to a point. The tangent will be automatically calculated by the derivative function, which is computed using Euler’s method with given delta. If the formula has cusps, you need to appropriately specify the range to put t at the cusp.

Parameters

ParameterTypeDescription
f(t) => vec2The formula to create the path
iterIterable<number>The iterable object to iterate the parameter t
optionsFormulaOptionsThe options

Returns

Path

The newly created path

Example


fromSegment()

fromSegment(segment): Path

Defined in: Path.ts:1027

Creates an open path consist of only a single command.

Parameters

ParameterTypeDescription
segmentSegmentThe segment to create

Returns

Path

The newly created path


grid()

grid(rect, divs): PathL

Defined in: Path.ts:893

Parameters

ParameterType
rectRect
divsvec2

Returns

PathL


halfLine()

halfLine(point, through, distance): Path

Defined in: Path.ts:338

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

ParameterTypeDefault valueDescription
pointvec2undefinedThe starting point
throughvec2undefinedThe point that the line passes through
distancenumber1e8The length of the half-line

Returns

Path

The half-line path


infiniteLine()

infiniteLine(point0, point1, distance): Path

Defined in: Path.ts:319

Creates an infinite line path from the given two points. Unlike line, the line will be drawn nearly infinitely in both directions.

Parameters

ParameterTypeDefault valueDescription
point0vec2undefinedThe first point
point1vec2undefinedThe second point
distancenumber1e8The length of the infinite line for each direction

Returns

Path

The infinite line path


line()

line(start, end): PathL

Defined in: Path.ts:775

Creates a linear path from two points describing a line.

Parameters

ParameterTypeDescription
startvec2The line’s starting point
endvec2The line’s ending point

Returns

PathL

The newly created path

Example


nBezier()

nBezier(points): Path<Vertex>

Defined in: Path.ts:976

Create a path consisting of cubic Bézier curves approximating the arbitrary higher-order Bézier curve.

Parameters

ParameterTypeDescription
pointsvec2[]The control points of the Bézier curve

Returns

Path<Vertex>

The newly created path


ngon()

ngon(center, radius, sides): PathL

Defined in: Path.ts:888

Alias for regularPolygon

Parameters

ParameterTypeDescription
centervec2The center of the polygon
radiusnumberThe radius of the circumcircle of the polygon
sidesnumberThe number o sides of the polygon

Returns

PathL

The newly created path

Example


polygon()

polygon(…points): PathL

Defined in: Path.ts:844

Creates a closed polyline from the given points.

Parameters

ParameterTypeDescription
…pointsvec2[]The points describing the polygon

Returns

PathL

The newly created path

Example


polyline()

polyline(…points): PathL

Defined in: Path.ts:822

Creates a open polyline from the given points.

Parameters

ParameterTypeDescription
…pointsvec2[]The points describing the polygon

Returns

PathL

The newly created path

Example


quadraticBezier()

quadraticBezier(start, control, point): Path

Defined in: Path.ts:960

Creates a quadratic Bézier curve path from the given points.

Parameters

ParameterTypeDescription
startvec2The start point
controlvec2The control point
pointvec2The end point

Returns

Path

THe newly created path


rect()

rect(start, end): Path

Defined in: Path.ts:197

Alias for rectangle

Parameters

ParameterTypeDescription
startvec2The first point defining the rectangle
endvec2The second point defining the rectangle

Returns

Path

The newly created path

Example


rectangle()

rectangle(start, end): Path

Defined in: Path.ts:177

Creates a rectangle path from the given two points.

Parameters

ParameterTypeDescription
startvec2The first point defining the rectangle
endvec2The second point defining the rectangle

Returns

Path

The newly created path

Example


rectFromCenter()

rectFromCenter(center, size): Path

Defined in: Path.ts:206

Creates a rectangle path from the given center and size.

Parameters

ParameterTypeDescription
centervec2The center of the rectangle
sizevec2The size of the rectangle

Returns

Path

The newly created path


regularPolygon()

regularPolygon(center, radius, sides): PathL

Defined in: Path.ts:868

Creates a regular polygon. The first vertex will be placed at the +X axis relative to the center.

Parameters

ParameterTypeDescription
centervec2The center of the polygon
radiusnumberThe radius of the circumcircle of the polygon
sidesnumberThe number o sides of the polygon

Returns

PathL

The newly created path

Example


roundRect()

roundRect(start, end, radii): Path

Defined in: Path.ts:218

Creates a rounded rectangle. The arguments are almost the same as the CanvasRenderingContext2D’s roundRect method.

Parameters

ParameterType
startvec2
endvec2
radiinumber | [number] | [number, number] | [number, number, number] | [number, number, number, number]

Returns

Path

See

https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/roundRect


semicircle()

semicircle(start, end, closed): Path

Defined in: Path.ts:303

Creates a semicircle path from the given start and end points.

Parameters

ParameterTypeDefault value
startvec2undefined
endvec2undefined
closedbooleantrue

Returns

Path

Properties

area()

area(arg): number

Defined in: Path.ts:1153

Calculates an area of the given path.

Parameters

ParameterType
argPath

Returns

number

The area of the path


bounds()

bounds(arg): Rect

Defined in: Path.ts:1143

Calculates the bound of the given path.

Parameters

ParameterType
argPath

Returns

Rect

The rect of the path

Example


derivative()

derivative(path, loc): vec2

Defined in: Path.ts:1387

Calculates the normalized tangent vector of the path at the given location.

Parameters

ParameterTypeDescription
pathPathThe path to calcuate
locPathLocationThe location on the path

Returns

vec2

The tangent vector


length()

length(arg): number

Defined in: Path.ts:1113

Returns the length of the given path. The returned value is memoized.

Parameters

ParameterType
argPath

Returns

number

The length of the path


normal()

normal(path, loc): vec2

Defined in: Path.ts:1411

Calculates the normalized tangent vector of the path at the given location.

Parameters

ParameterTypeDescription
pathPathThe path to calcuate
locPathLocation-

Returns

vec2

The tangent vector


orientation()

orientation(path, loc): mat2d

Defined in: Path.ts:1423

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

ParameterTypeDescription
pathPathThe path to calculate
locPathLocation-

Returns

mat2d

The transformation matrix at the given offset


point()

point(path, loc): vec2

Defined in: Path.ts:1375

Calculates the position on the path at the given location.

Parameters

ParameterTypeDescription
pathPathThe path to calculate
locPathLocationThe location on the path

Returns

vec2

The position at the given offset


segment()

segment(path, curveIndex, segmentIndex?): Segment

Defined in: Path.ts:1178

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

ParameterTypeDescription
pathPathThe path that contains the segment
curveIndexnumberThe index of the curve.
segmentIndex?numberThe index of the segment in the curve.

Returns

Segment

The segment


segmentCount()

segmentCount(arg): number

Defined in: Path.ts:1163

Returns the count of segments in the given path.

Parameters

ParameterType
argPath

Returns

number

The count of segments in the path


segments()

segments(arg): Segment[]

Defined in: Path.ts:2231

Returns all segmentse

Parameters

ParameterType
argPath

Returns

Segment[]


tangent()

tangent(path, loc): vec2

Defined in: Path.ts:1399

Calculates the normalized tangent vector of the path at the given location.

Parameters

ParameterTypeDescription
pathPathThe path to calcuate
locPathLocation-

Returns

vec2

The tangent vector

Modifiers

chamfer()

chamfer(path, distance): Path

Defined in: Path.ts:2021

Chamfers the given path.

Parameters

ParameterTypeDescription
pathPathThe path to chamfer
distancenumberThe distance of chamfer

Returns

Path

The newly created path


distort()

distort(path, transform, __namedParameters): Path<Vertex>

Defined in: Path.ts:1992

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

ParameterTypeDescription
pathPathThe path to distort
transform(position) => mat2dThe 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.
__namedParametersDistortOptions-

Returns

Path<Vertex>

The newly created path

Example


fillet()

fillet(path, radius): Path

Defined in: Path.ts:2042

Fillets the given path.

Parameters

ParameterTypeDescription
pathPathThe path to fillet
radiusnumberThe radius of fillet

Returns

Path

The newly created path


flatten()

flatten(path, flatness): Path

Defined in: Path.ts:1906

Flattens the curves in path to straight lines.

Parameters

ParameterTypeDefault valueDescription
pathPathundefinedThe path to flatten
flatnessnumber0.25The maximum distance between the path and the flattened path

Returns

Path

The flattened path consists of only M, L, and Z commands

See

http://paperjs.org/reference/path/#flatten

Example


join()

join(paths): Path

Defined in: Path.ts:1869

Joins the given paths into a single open paths.

Parameters

ParameterTypeDescription
pathsPath<Vertex>[]The paths to join

Returns

Path

The joined path


merge()

merge(pathOrCurves): Path

Defined in: Path.ts:1884

Merges the given paths into a single path. Unlike join or unite, the vertices are not connected, and it simply returns compound path.

Parameters

ParameterType
pathOrCurves(Curve | Path<Vertex>)[]

Returns

Path


offset()

offset(path, offset, options?): Path

Defined in: Path.ts:1803

Creates an offset path from the given path.

Parameters

ParameterTypeDescription
pathPathThe path to offset
offsetnumberThe width of offset
options?OffsetOptionsThe options

Returns

Path

The newly created path

Example


offsetStroke()

offsetStroke(path, width, options?): Path<Vertex>

Defined in: Path.ts:1845

Creates an offset path from the given path.

Parameters

ParameterTypeDescription
pathPathThe path to offset
widthnumberThe width of stroke
options?OffsetStrokeOptionsThe options

Returns

Path<Vertex>

The newly created path

Example


reduce()

reduce(path, options): Path

Defined in: Path.ts:2901

Cleans up the path by removing redundant vertices and

Parameters

ParameterTypeDescription
pathPath
optionsReduceOptions-

Returns

Path


reverse()

reverse(path, options:): Path

Defined in: Path.ts:1640

Reverses the given path.

Parameters

ParameterTypeDescription
pathPathThe path to reverse
options:ReverseOptionsThe options

Returns

Path

The reversed path


spawn()

spawn(path, fn, __namedParameters): Path

Defined in: Path.ts:1516

Maps each segments in the path to a path and create a new path concatinating those paths.

Parameters

ParameterType
pathPath
fn(seg, segmentIndex, curve) => Path
__namedParametersSpawnOptions

Returns

Path


spawnCurve()

spawnCurve<V1, V2>(path, fn): Path<V2>

Defined in: Path.ts:1489

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 ParameterDefault type
V1 extends VertexVertex
V2 extends VertexVertex

Parameters

ParameterTypeDescription
pathPath<V1>The path to map
fn(curve, curveIndex) => Curve<V2> | Curve<V2>[]The curve mapping function.

Returns

Path<V2>

The newly created path


spawnVertex()

spawnVertex<V1, V2>(path, fn): Path<V2>

Defined in: Path.ts:1435

Maps each segment in the path to a single or array of vertices and creates a new path concatinating those vertices. Unlike spawn, the mapping function must returns a single or multiple vertices instead of Path. So while you can change the type of commands, and change the number of them in the path, you cannot change the topology of the path. The segments that were originally continuous remains connected, and vice versa.

Type Parameters

Type ParameterDefault type
V1 extends VertexVertex
V2 extends VertexVertex

Parameters

ParameterTypeDescription
pathPath<V1>The path to map
fn(segment, segmentIndex, curve) => V2 | V2[]The vertex mapping function. It takes a Segment and returns a single or array of vertices.

Returns

Path<V2>

The newly created path


split()

split(path, locs): Path<Vertex>[]

Defined in: Path.ts:1946

Splits the path into multiple paths at the given locations.

Parameters

ParameterTypeDescription
pathPathThe path to split
locsIterable<PathLocation>The locations to split

Returns

Path<Vertex>[]

The splitted paths


subdiv()

subdiv(path, division): Path

Defined in: Path.ts:1937

Alias for subdivide

Parameters

ParameterTypeDescription
pathPathThe path to subdivide
divisionnumberThe number of division for each segment

Returns

Path

The newly created path


subdivide()

subdivide(path, division): Path

Defined in: Path.ts:1919

Subdivides each segment in the path into specific number of sub-segments.

Parameters

ParameterTypeDescription
pathPathThe path to subdivide
divisionnumberThe number of division for each segment

Returns

Path

The newly created path


toC()

toC(path, unarcAngle): PathC

Defined in: Path.ts:1765

Alias for toCubicBezier

Parameters

ParameterTypeDefault valueDescription
pathPathundefinedThe path to convert
unarcAnglenumber90The angle step for approximating arc commands with cubic Béziers

Returns

PathC

The new path with only cubic Bézier curve commands


toCubicBezier()

toCubicBezier(path, unarcAngle): PathC

Defined in: Path.ts:1747

Converts all commands in the path to cubic Bézier curve commands.

Parameters

ParameterTypeDefault valueDescription
pathPathundefinedThe path to convert
unarcAnglenumber90The angle step for approximating arc commands with cubic Béziers

Returns

PathC

The new path with only cubic Bézier curve commands


transform()

transform(path, matrix): Path

Defined in: Path.ts:1603

Transforms the given path by the given matrix.

Parameters

ParameterTypeDescription
pathPathThe path to transform
matrixmat2dThe matrix to transform the path by

Returns

Path

The transformed path


trim()

trim(path, from, to, crossFirstPoint): Path

Defined in: Path.ts:1657

Trims the path from the given location to the given location.

Parameters

ParameterTypeDefault valueDescription
pathPathundefinedThe path to trim
fromPathLocationundefinedThe start location
toPathLocationundefinedThe end location
crossFirstPointbooleantrue-

Returns

Path

The trimmed path


unarc()

unarc(path, angle): UnarcPath

Defined in: Path.ts:1730

Parameters

ParameterTypeDefault valueDescription
pathPathundefined
anglenumber90

Returns

UnarcPath

Example

Boolean Operations

subtract()

subtract(subject, tools): Path

Defined in: Path.ts:2098

Subtracts the tools from the subject.

Parameters

ParameterTypeDescription
subjectPathThe target path to be subtracted
toolsPath<Vertex>[]The paths to subtract

Returns

Path

The resulting path


unite()

unite(paths): Path

Defined in: Path.ts:2080

Unites the given paths.

Parameters

ParameterTypeDescription
pathsPath<Vertex>[]The paths to unite

Returns

Path

The resulting path

Converters

drawToCanvas()

drawToCanvas(path, context): void

Defined in: Path.ts:2520

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

ParameterTypeDescription
pathPathThe path to draw
contextCanvasRenderingContext2D | OffscreenCanvasRenderingContext2DThe Canvas context

Returns

void


drawToP5()

drawToP5(path, p5Instance): void

Defined in: Path.ts:2535

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

ParameterTypeDefault valueDescription
pathPathundefinedThe path to draw
p5Instance__module | WindowwindowThe 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:2158

Alias for fromSVGString

Parameters

ParameterTypeDescription
dstringThe d attribute of an SVG path

Returns

Path

The newly created path


fromPaperPath()

fromPaperPath(arg): Path

Defined in: Path.ts:2668

Creates a path from the given paper.Path instance.

Parameters

ParameterType
argPathItem

Returns

Path

The newly created path


fromSVG()

fromSVG(commands): Path

Defined in: Path.ts:2241

Converts an array of SVG commands to a Path.

Parameters

ParameterTypeDescription
commandsSVGCommand[]The array of SVG commands

Returns

Path

The newly created path


fromSVGString()

fromSVGString(d): Path

Defined in: Path.ts:2118

Parses the given d attribute of an SVG path and creates a new path. Internally uses svgpath library.

Parameters

ParameterTypeDescription
dstringThe d attribute of an SVG path

Returns

Path

The newly created path


toD()

toD(path): string

Defined in: Path.ts:2224

Alias for toSVGString

Parameters

ParameterTypeDescription
pathPathThe path to convert

Returns

string

The string for the d attribute of the SVG path element


toPaperPath()

toPaperPath(arg): Path | CompoundPath

Defined in: Path.ts:2596

Converts the given path to paper.Path

Parameters

ParameterType
argPath

Returns

Path | CompoundPath

The newly created paper.Path instance

See

http://paperjs.org/reference/pathitem/


toPath2D()

toPath2D(arg): Path2D

Defined in: Path.ts:2506

Creates a Path2D instance with the given path data.

Parameters

ParameterType
argPath

Returns

Path2D

The newly created Path2D


toSVGString()

toSVGString(path): string

Defined in: Path.ts:2166

Converts the given path to a string that can be used as the d attribute of an SVG path element.

Parameters

ParameterTypeDescription
pathPathThe 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:2735

Appends the given command to the end of the path.

Parameters

ParameterTypeDescription
pathPathThe base path
vertexVertex-

Returns

Path

The newely created path


arcTo()

arcTo(path, radii, xAxisRotation, largeArcFlag, sweepFlag, point): Path

Defined in: Path.ts:2833

Returns the new path with the new A (arc) command at the end.

Parameters

ParameterTypeDescription
pathPathThe base path
radiivec2The radii of the ellipse used to draw the arc
xAxisRotationnumberThe rotation angle of the ellipse’s x-axis relative to the x-axis of the current coordinate system, expressed in degrees
largeArcFlagbooleanThe large arc flag. If true, then draw the arc spanning greather than 180 degrees. Otherwise, draw the arc spanning less than 180 degrees.
sweepFlagbooleanThe 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.
pointvec2The end point of the arc

Returns

Path

The newely created path


close()

close(path, __namedParameters): Path

Defined in: Path.ts:2871

Closes the specified curves

Parameters

ParameterTypeDescription
pathPathThe base path
__namedParametersPathCloseOptions-

Returns

Path

The newely created path


cubicBezierTo()

cubicBezierTo(path, control1, control2, point): Path

Defined in: Path.ts:2780

Returns the new path with the new C (cubic Bézier curve) command at the end.

Parameters

ParameterTypeDescription
pathPathThe base path
control1vec2The first control point
control2vec2The second control point
pointvec2The end point

Returns

Path

The newely created path


lineTo()

lineTo(path, point): Path

Defined in: Path.ts:2767

Returns the new path with the new L (line-to) command at the end.

Parameters

ParameterTypeDescription
pathPathThe base path
pointvec2The point to draw a line to

Returns

Path

The newely created path


moveTo()

moveTo(path, point): Path

Defined in: Path.ts:2715

Returns the new path with the new M (move-to) command at the end.

Parameters

ParameterTypeDescription
pathPathThe base path
pointvec2The point to move to

Returns

Path

The newely created path


pen()

pen(): Pen

Defined in: Path.ts:2917

Creates a new Path instance to begin drawing a path.

Returns

Pen


Pen

Defined in: Path.ts:2925

A class for creating a path by calling draw functions, like Canvas API.

Constructors

new Pen()

new Pen(): Pen

Returns

Pen

Properties

PropertyType
currentundefined | { curve: Curve; lastHandle: vec2; point: vec2; }

Methods

a()

a(radii, xAxisRotation, largeArcFlag, sweepFlag, deltaPoint): Pen

Defined in: Path.ts:3255

Parameters
ParameterType
radiivec2
xAxisRotationnumber
largeArcFlagboolean
sweepFlagboolean
deltaPointvec2
Returns

Pen

A()

A(radii, xAxisRotation, largeArcFlag, sweepFlag, point): Pen

Defined in: Path.ts:3227

Parameters
ParameterType
radiivec2
xAxisRotationnumber
largeArcFlagboolean
sweepFlagboolean
pointvec2
Returns

Pen

arcBy()

arcBy(radii, xAxisRotation, largeArcFlag, sweepFlag, deltaPoint): Pen

Defined in: Path.ts:3237

Parameters
ParameterType
radiivec2
xAxisRotationnumber
largeArcFlagboolean
sweepFlagboolean
deltaPointvec2
Returns

Pen

arcTo()

arcTo(radii, xAxisRotation, largeArcFlag, sweepFlag, point): Pen

Defined in: Path.ts:3206

Parameters
ParameterType
radiivec2
xAxisRotationnumber
largeArcFlagboolean
sweepFlagboolean
pointvec2
Returns

Pen

c()

c(deltaControl1, deltaControl2, deltaPoint): Pen

Defined in: Path.ts:3163

Parameters
ParameterType
deltaControl1vec2
deltaControl2vec2
deltaPointvec2
Returns

Pen

C()

C(control1, control2, point): Pen

Defined in: Path.ts:3145

Parameters
ParameterType
control1vec2
control2vec2
pointvec2
Returns

Pen

close()

close(removeOverwrapped): Pen

Defined in: Path.ts:3271

Parameters
ParameterTypeDefault value
removeOverwrappedbooleantrue
Returns

Pen

cubicBezierBy()

cubicBezierBy(deltaControl1, deltaControl2, deltaPoint): Pen

Defined in: Path.ts:3149

Parameters
ParameterType
deltaControl1vec2
deltaControl2vec2
deltaPointvec2
Returns

Pen

cubicBezierTo()

cubicBezierTo(control1, control2, point): Pen

Defined in: Path.ts:3129

Parameters
ParameterType
control1vec2
control2vec2
pointvec2
Returns

Pen

get()

get(): Path

Defined in: Path.ts:3301

Returns the path drawn by the pen so far.

Returns

Path

h()

h(dx): Pen

Defined in: Path.ts:3016

Parameters
ParameterType
dxnumber
Returns

Pen

H()

H(x): Pen

Defined in: Path.ts:3001

Parameters
ParameterType
xnumber
Returns

Pen

horizBy()

horizBy(dx): Pen

Defined in: Path.ts:3005

Parameters
ParameterType
dxnumber
Returns

Pen

horizTo()

horizTo(x): Pen

Defined in: Path.ts:2990

Parameters
ParameterType
xnumber
Returns

Pen

l()

l(delta): Pen

Defined in: Path.ts:2986

Parameters
ParameterType
deltavec2
Returns

Pen

L()

L(point): Pen

Defined in: Path.ts:2971

Parameters
ParameterType
pointvec2
Returns

Pen

lineBy()

lineBy(delta): Pen

Defined in: Path.ts:2975

Parameters
ParameterType
deltavec2
Returns

Pen

lineTo()

lineTo(point): Pen

Defined in: Path.ts:2960

Parameters
ParameterType
pointvec2
Returns

Pen

m()

m(delta): Pen

Defined in: Path.ts:2956

Parameters
ParameterType
deltavec2
Returns

Pen

M()

M(point): Pen

Defined in: Path.ts:2941

Parameters
ParameterType
pointvec2
Returns

Pen

moveBy()

moveBy(delta): Pen

Defined in: Path.ts:2945

Parameters
ParameterType
deltavec2
Returns

Pen

moveTo()

moveTo(point): Pen

Defined in: Path.ts:2930

Parameters
ParameterType
pointvec2
Returns

Pen

q()

q(delta, delta2): Pen

Defined in: Path.ts:3087

Parameters
ParameterType
deltavec2
delta2vec2
Returns

Pen

Q()

Q(control, point): Pen

Defined in: Path.ts:3070

Parameters
ParameterType
controlvec2
pointvec2
Returns

Pen

quadraticCurveBy()

quadraticCurveBy(deltaControl, deltaPoint): Pen

Defined in: Path.ts:3074

Parameters
ParameterType
deltaControlvec2
deltaPointvec2
Returns

Pen

quadraticCurveTo()

quadraticCurveTo(control, point): Pen

Defined in: Path.ts:3050

Parameters
ParameterType
controlvec2
pointvec2
Returns

Pen

s()

s(deltaControl2, deltaPoint): Pen

Defined in: Path.ts:3202

Parameters
ParameterType
deltaControl2vec2
deltaPointvec2
Returns

Pen

S()

S(control2, point): Pen

Defined in: Path.ts:3181

Parameters
ParameterType
control2vec2
pointvec2
Returns

Pen

smoothCubicBezierBy()

smoothCubicBezierBy(deltaControl2, deltaPoint): Pen

Defined in: Path.ts:3185

Parameters
ParameterType
deltaControl2vec2
deltaPointvec2
Returns

Pen

smoothCubicBezierTo()

smoothCubicBezierTo(control2, point): Pen

Defined in: Path.ts:3167

Parameters
ParameterType
control2vec2
pointvec2
Returns

Pen

smoothQuadraticCurveBy()

smoothQuadraticCurveBy(delta): Pen

Defined in: Path.ts:3109

Parameters
ParameterType
deltavec2
Returns

Pen

smoothQuadraticCurveTo()

smoothQuadraticCurveTo(point): Pen

Defined in: Path.ts:3091

Parameters
ParameterType
pointvec2
Returns

Pen

t()

t(delta): Pen

Defined in: Path.ts:3125

Parameters
ParameterType
deltavec2
Returns

Pen

T()

T(point): Pen

Defined in: Path.ts:3105

Parameters
ParameterType
pointvec2
Returns

Pen

v()

v(dy): Pen

Defined in: Path.ts:3046

Parameters
ParameterType
dynumber
Returns

Pen

V()

V(y): Pen

Defined in: Path.ts:3031

Parameters
ParameterType
ynumber
Returns

Pen

vertBy()

vertBy(dy): Pen

Defined in: Path.ts:3035

Parameters
ParameterType
dynumber
Returns

Pen

vertTo()

vertTo(y): Pen

Defined in: Path.ts:3020

Parameters
ParameterType
ynumber
Returns

Pen

Z()

Z(removeOverwrapped): Pen

Defined in: Path.ts:3294

Parameters
ParameterTypeDefault value
removeOverwrappedbooleantrue
Returns

Pen


quadraticBezierTo()

quadraticBezierTo(path, control, point): Path

Defined in: Path.ts:2801

Returns the new path with the new Q (quadratic Bézier curve) command at the end.

Parameters

ParameterTypeDescription
pathPathThe base path
controlvec2The control point
pointvec2The end point

Returns

Path

The newely created path

Utilities

toTime()

toTime(path, location): Required<TimePathLocation> & object

Defined in: Path.ts:1226

Retrieves the segment location information from the given path and path-based signed location.

Parameters

ParameterTypeDescription
pathPathThe path to retrieve the segment location
locationPathLocationThe path-based location

Returns

Required<TimePathLocation> & object

The information of the segment location


unlinearSegmentIndex()

unlinearSegmentIndex(path, linearSegmentIndex): object

Defined in: Path.ts:1344

Converts a signed linear segment index to a pair of curve and unsgined segment index.

Parameters

ParameterType
pathPath
linearSegmentIndexnumber

Returns

object

NameType
curveIndexnumber
segmentIndexnumber

Aliases

fromD()

fromD(d): Path

Defined in: Path.ts:2158

Alias for fromSVGString

Parameters

ParameterTypeDescription
dstringThe d attribute of an SVG path

Returns

Path

The newly created path


subdiv()

subdiv(path, division): Path

Defined in: Path.ts:1937

Alias for subdivide

Parameters

ParameterTypeDescription
pathPathThe path to subdivide
divisionnumberThe number of division for each segment

Returns

Path

The newly created path


toC()

toC(path, unarcAngle): PathC

Defined in: Path.ts:1765

Alias for toCubicBezier

Parameters

ParameterTypeDefault valueDescription
pathPathundefinedThe path to convert
unarcAnglenumber90The angle step for approximating arc commands with cubic Béziers

Returns

PathC

The new path with only cubic Bézier curve commands


toD()

toD(path): string

Defined in: Path.ts:2224

Alias for toSVGString

Parameters

ParameterTypeDescription
pathPathThe path to convert

Returns

string

The string for the d attribute of the SVG path element

Options

ArcOptions

ArcOptions: object

Defined in: Path.ts:502

An options for arc

Type declaration

NameTypeDescription
align?ResampleOptions["align"]The alignment of the vertices Default 'uniform'
count?numberThe total count of the segments in the arc. If this is specified, the step will be ignored and the arc will be deviced into the specified number of segments uniformly.
step?numberThe maximum angle step in degrees Default 360 - 1e-4

CircleFromPointsOptions

Defined in: Path.ts:347

Properties

PropertyTypeDescription
preferredSweep?booleanIf the given points are less than three and the circumcenter cannot be well-defined, the circle will be drawn in the direction of the sweep flag. (in Canvas API, it means clockwise). Default true

DistortOptions

Defined in: Path.ts:1955

Properties

PropertyTypeDescription
subdivide?numberThe number of subdivision for each segment Default 1 (no subdivision applied)
unarcAngle?numberThe angle step for approximating arc commands with cubic Béziers Default 5

FormulaOptions

Defined in: Path.ts:1049

The options for formula

Properties

PropertyTypeDescription
delta?numberThe delta value for calculating the derivative of the formula Default 10e-6

OffsetOptions

Defined in: Path.ts:1770

Extended by

  • OffsetStrokeOptions

Properties

PropertyTypeDefault valueDescription
cap?StrokeCapTypeundefinedThe cap style of offset path
join?CanvasLineJoin'miter'The join style of offset path
miterLimit?number10The limit for miter style See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimit

OffsetStrokeOptions

Defined in: Path.ts:1822

Extends

  • OffsetOptions

Properties

PropertyTypeDefault valueDescriptionInherited from
cap?StrokeCapTypeundefinedThe cap style of offset pathOffsetOptions.cap
join?CanvasLineJoin'miter'The join style of offset pathOffsetOptions.join
lineCap?"round" | "butt"'butt'The cap style of offset path ('square' will be supported in future)-
miterLimit?number10The limit for miter style See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/miterLimitOffsetOptions.miterLimit

PathCloseOptions

PathCloseOptions: object

Defined in: Path.ts:2852

An options for close

Type declaration

NameTypeDescription
fuse?booleanIf true, deletes overwrapped first and last vertices. Default true
group?CurveGroupSpecifies which curves to close. Default is the last curve. Default -1

ReduceOptions

ReduceOptions: ReduceOptions & object

Defined in: Path.ts:2888

An options for reduce

Type declaration

NameTypeDescription
removeEmptyCurves?booleanIf true, removes the curves with zero length Default true

ReverseOptions

Defined in: Path.ts:1625

An options for reverse

Properties

PropertyTypeDefault valueDescription
per?"curve" | "path"'path'The unit to reverse the path.

SpawnOptions

Defined in: Path.ts:1504

Properties

PropertyTypeDefault valueDescription
join?booleantrueIf true, the continuous open path will be joined
Edit this page