Constructor
new Path2D(points)
Creates a new Path2D with the given points.
Name | Type | Description |
---|---|---|
points | Array.<Point2D> | The points of the path. |
- Source
Classes
Members
cubic_bezier_tuples
Returns a CubicBezierTuple at a given index.
- Source
first
Gets the first point of the Path2D.
- Source
is_empty
Returns whether the Path2D is empty.
- Source
last
Gets the last point of the Path2D.
- Source
len
Returns the length of the Path2D.
- Source
points
Returns the Point2Ds of the Path2D.
- Source
points
Sets the Point2Ds of the Path2D.
- Source
Methods
clear()
Removes all Point2Ds from the Path2D.
- Source
clone() → {Path2D}
Clones the Path2D.
- Source
- Type:
- Path2D
closest_point(point) → {Point2D}
Returns the closest Point2D in the Path2D to a given Point2D.
Name | Type | Description |
---|---|---|
point | Point2D | The point to find the closest point to. |
- Source
The closest point in the path.
- Type:
- Point2D
get(index) → {Point2D}
Returns the Point2D at a given index.
Name | Type | Description |
---|---|---|
index | number | The index of the point. |
- Source
The first point of the path.
- Type:
- Point2D
insert(index, point)
Inserts a Point2D at a given index.
Name | Type | Description |
---|---|---|
index | number | The index to insert the point at. |
point | Point2D | The point to insert. |
- Source
length(samples_per_cubicopt, extra_length_per_cubicopt) → {number}
Returns an approximation of the length of the path, based on sampling points along each cubic bezier curve in the path and an optional extra length to add to each approximation.
Name | Type | Attributes | Description |
---|---|---|---|
samples_per_cubic | number | | <optional> | The number of samples to take along each cubic bezier curve. |
extra_length_per_cubic | number | | <optional> | An optional extra length to add to each cubic bezier length approximation. |
- Source
An approximation of the length of the path.
- Type:
- number
partial_bezier_path(a, b) → {Path2D}
Returns a new Path2D representing a bezier curve portion of the Path2D.
Name | Type | Description |
---|---|---|
a | number | The start proportion of the input path. A number between 0 and 1. |
b | number | The end proportion of the input path. A number between 0 and 1. |
- Source
A Path2D object representing the portion of the input path.
- Type:
- Path2D
pop() → {Point2D|undefined}
Removes the last Point2D from the Path2D.
- Source
The last point of the path.
- Type:
- Point2D |
undefined
push(point)
Appends a Point2D to the Path2D.
Name | Type | Description |
---|---|---|
point | Point2D | The point to append. |
- Source
push_bezier(cubic_bezier)
Appends a CubicBezierTuple to the Path2D.
Name | Type | Description |
---|---|---|
cubic_bezier | CubicBezierTuple | The cubic bezier tuple to add. |
- Source
remove(index) → {Point2D}
Removes a Point2D at a given index.
Name | Type | Description |
---|---|---|
index | number | The index of the point to remove. |
- Source
The removed point.
- Type:
- Point2D
repeat(count) → {Path2D}
Repeats the Path2D a given number of times.
Name | Type | Description |
---|---|---|
count | number | The number of times to repeat the path. |
- Source
The repeated path.
- Type:
- Path2D
reverse()
Reverse the Path2D.
- Source
set(index, point)
Sets the Point2D at the given index.
Name | Type | Description |
---|---|---|
index | number | The index of the point. |
point | Point2D | The new point. |
- Source
set_slice(start, end, path)
Sets a slice of the Path2D.
Name | Type | Description |
---|---|---|
start | number | The start index of the slice. |
end | number | The end index of the slice. |
path | Path2D | The new path. |
- Source
slice(start, end) → {Path2D}
Returns a slice of the Path2D
Name | Type | Description |
---|---|---|
start | number | The start index of the slice. |
end | number | The end index of the slice. |
- Source
A slice of the path.
- Type:
- Path2D
(static) fill(point, count) → {Path2D}
Creates a new Path2D by filling the Path2D with a given Point2D a given number of times.
Name | Type | Description |
---|---|---|
point | Point2D | The point to fill the path with. |
count | number | The number of times to fill the path with the point. |
- Source
A path that is a portion of the input path.
- Type:
- Path2D
(static) from_anchors_and_handles(anchors_and_handles) → {Path2D}
Creates a new Path2D given a AnchorsAndHandles object.
Name | Type | Description |
---|---|---|
anchors_and_handles | AnchorsAndHandles | The AnchorsAndHandles object. |
- Source
A 2D path.
- Type:
- Path2D