Private
constructorThe 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.
BezierPath
Set this flag to true if you want the first point and last point of the path to be auto adjusted, too.
BezierPath
BezierPath
Readonly
classRequired to generate proper CSS classes and other class related IDs.
BezierPath
BezierPath
BezierPath
Readonly
uidThe UID of this drawable object.
BezierCurve
Static
END_Static
END_Static
START_Static
START_Add a cubic bezier curve to the end of this path.
The curve to be added to the end of the path.
addCurve
BezierPath
Private
adjustPrivate
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.
adjustPredecessorControlPoint
BezierPath
Private
adjustPrivate
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.
adjustSuccessorControlPoint
BezierPath
Clone this BezierPath (deep clone).
clone
BezierPath
Compare this and the passed Bézier path.
The pass to compare with.
equals
BezierPath
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.
getCurveAt
BezierPath
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 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.
getPerpendicular
BezierPath
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.
getPerpendicularAt
BezierPath
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].
getSubPathAt
BezierPath
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.
getTangent
BezierPath
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.
getTangentAt
BezierPath
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
locateCurveByEndPoint
BezierPath
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
locateCurveByStartControlPoint
BezierPath
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
locateCurveByStartPoint
BezierPath
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.
moveCurvePoint
BezierPath
Rotate the whole bezier path around a point..
The angle to rotate this path by.
The rotation center.
rotate
BezierPath
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
BezierPath
Scale the whole bezier path by the given (x,y)-factors.
this for chaining.
scale
BezierPath
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.
toReducedListRepresentation
BezierPath
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
translate
BezierPath
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.
updateArcLengths
BezierPath
Static
Private
_locateUIndexThis 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:
Static
Private
adjustPrivate
This helper function adjusts the given point's successor's control point.
adjustNeighbourControlPoint
BezierPath
Static
fromCreate a BezierPath instance from the given array.
The bezier path instance retrieved from the array data.
fromArray
An error if the array does not contain proper bezier path data.
BezierPath
Static
fromConstruct 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.
fromCurve
BezierPath
Static
fromJSONParse a BezierPath from the given JSON string.
The string with the JSON data.
The parsed bezier path instance.
fromJSON
An error if the string is not JSON or does not contain a bezier path object.
BezierPath
Static
fromConvert a reduced list representation (array of numeric coordinates) to a BezierPath instance.
The array's length must be 6*n + 2:
Optional
adjustCircular: booleanBezierPath
Static
fromParse 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.
Optional
adjustCircular: booleanThe bezier path instance retrieved from the string.
fromReducedListRepresentation
An error if the string is malformed.
BezierPath
Classdesc
A BezierPath class.
This was refactored from an older project.
Requires
Bounds
Requires
Vertex
Requires
CubicBezierCurve
Requires
XYCoords
Requires
SVGSerializable
Requires
UID
Requires
UIDGenerator