The constructor.
This constructor expects a sequence of path points and will approximate
the location of control points by picking some between the points.
You should consider just constructing empty paths and then add more curves later using
the addCurve() function.
Set this flag to true if you want the first point and last point of the path to be auto adjusted, too.
Required to generate proper CSS classes and other class related IDs.
The UID of this drawable object.
Add a cubic bezier curve to the end of this path.
The curve to be added to the end of the path.
This helper function adjusts the given point's predecessor's control point.
The curve index to move a point from.
Moves the point with keeping the original handle length.
This helper function adjusts the given point's successor's control point.
The curve index to move a point from.
Moves the point with keeping the original handle length.
Clone this BezierPath (deep clone).
This function should invalidate any installed listeners and invalidate this object. After calling this function the object might not hold valid data any more and should not be used.
Compare this and the passed Bézier path.
The pass to compare with.
Get the bounds of this Bézier path.
Note the the curves' underlyung segment buffers are used to determine the bounds. The more elements the segment buffers have, the more precise the returned bounds will be.
The bounds of this Bézier path.
Get the 't' position on this curve with the minimal distance to point p.
The point to find the closest curve point for.
A value t with 0.0 <= t <= 1.0.
Get the cubic bezier curve at the given index.
The curve at the specified index.
Get the number of curves in this path.
The number of curves in this path.
Get n 'equally' distributed vertices along this Bézier path.
As the changing curvature of the B slines makes prediction of distances difficult, the returned vertices' distances are only relatively equal:
Only the distance mean of all consecutive is 1/n-th of the total arc length.
Usually this approximation is good enough for most use cases.
(must be at least 2) The number of desired points (start and end point included).
Get the total length of this path.
Note that the returned value comes from the curve buffer. Unregistered changes
to the curve points will result in invalid path length values.
The (buffered) length of the path.
Get the perpendicular of the bézier path at the given relative path location.
Note that the returned vector is not normalized.
The relative path position:
0 <= u <= getLength()
The perpendicluar vector at the relative path position.
Get the perpendicular of the bézier path at the given absolute path location (fraction).
Note that the returned vector is not normalized.
The absolute path position:
0.0 <= t <= 1.0
The perpendicluar vector at the absolute path position.
Get the point on the bézier path at the given relative path location.
The relative path position:
0 <= u <= this.getLength()
The point at the relative path position.
Get the point on the bézier path at the given path fraction.
The absolute path position:
0.0 <= t <= 1.0
The point at the absolute path position.
Get a specific sub path from this path. The start and end position are specified by ratio number in [0..1].
0.0 is at the beginning of the path. 1.0 is at the end of the path.
Values below 0 or beyond 1 are cropped down to the [0..1] interval.
startT > endT is allowed, the returned sub path will have inverse direction then.
The start position of the sub path.
The end position of the sub path.
The desired sub path in the bounds [startT..endT].
Get the tangent of the bézier path at the given path location.
Note that the returned vector is not normalized.
The relative path position:
0 <= u <= getLength()
The tangent vector at the relative path position.
Get the tangent of the bézier path at the given path fraction.
Note that the returned vector is not normalized.
The absolute path position:
0.0 <= t <= 1.0
The tangent vector at the absolute path position.
Locate the curve with the given end point (function returns the index).
The (curve end-) point to look for.
The curve index or -1 if curve (end-) point not found
Locate the curve with the given start point (function returns the index).
The (curve endt-) point to look for.
The curve index or -1 if curve (end-) point not found
Locate the curve with the given start point (function returns the index).
The (curve start-) point to look for.
The curve index or -1 if curve (start-) point not found
This function moves the addressed curve point (or control point) with
keeping up the path's curve integrity.
Thus is done by moving neighbour- and control- points as needed.
The curve index to move a point from.
One of the curve's four point IDs (START_POINT, START_CONTROL_POINT, END_CONTRO_POINT or END_POINT).
The amount to move the addressed vertex by.
Rotate the whole bezier path around a point..
The angle to rotate this path by.
The rotation center.
Scale the whole bezier path by the given uniform factor.
The scale origin to scale from.
The scalar to be multiplied with.
this for chaining.
Scale the whole bezier path by the given (x,y)-factors.
this for chaining.
Create a JSON string representation of this bézier curve.
If true then the function will add line breaks.
The JSON string.
Convert this path to an array of path points that can be drawn by the default DrawLib implementations.
This function converts the bezier path into a string containing integer values only. The points' float values are rounded to 1 digit after the comma.
The returned string represents a JSON array (with leading '[' and trailing ']', the separator is ',').
The number of digits to be used after the comma '.'.
The reduced list representation of this path.
Move the whole bezier path by the given (x,y)-amount.
The amount to be added (amount.x and amount.y) to each vertex of the curve.
this for chaining
This function is internally called whenever the curve or path configuration
changed. It updates the attribute that stores the path length information.
If you perform any unregistered changes to the curve points you should call
this function afterwards to update the curve buffer. Not updating may
result in unexpected behavior.
This is a helper function to locate the curve index for a given absolute path position u.
I decided to put this into privat scope as it is really specific. Maybe put this into a utils wrapper.
Returns:
This helper function adjusts the given point's successor's control point.
Create a BezierPath instance from the given array.
The bezier path instance retrieved from the array data.
Construct a new path with a single curve. Adding more curves is always possible.
The curve to construct a new path from.
The constructed bezier path instance.
Parse a BezierPath from the given JSON string.
The string with the JSON data.
The parsed bezier path instance.
Convert a reduced list representation (array of numeric coordinates) to a BezierPath instance.
The array's length must be 6*n + 2:
BezierPath
Parse a BezierPath instance from the reduced list representation.
The passed string must represent a JSON array containing numbers only.
The number of digits to be used after the floating point.
The bezier path instance retrieved from the string.
Generated using TypeDoc
A BezierPath class.
This was refactored from an older project.
Bounds
Vertex
CubicBezierCurve
XYCoords
SVGSerializable
UID
UIDGenerator