Curve
The Curve object represents the parts of a path that are connected by two following Segment objects. The curves of a path can be accessed through its path.curves array.
While a segment describe the anchor point and its incoming and outgoing handles, a Curve object describes the curve passing between two such segments. Curves and segments represent two different ways of looking at the same thing, but focusing on different aspects. Curves for example offer many convenient ways to work with parts of the path, finding lengths, positions or tangents at given offsets.
Constructors
Properties
Specifies whether the points and handles of the curve are selected.
 Boolean
Type:
An array of 8 float values, describing this curve’s geometry in four absolute x/y pairs (point1, handle1, handle2, point2). This format is used internally for efficient processing of curve geometries, e.g. when calculating intersections or bounds.
Note that the handles are converted to absolute coordinates.
Read only.
 Array of Numbers
Type:
An array of 4 point objects, describing this curve’s geometry in absolute coordinates (point1, handle1, handle2, point2).
Note that the handles are converted to absolute coordinates.
Read only.
 Array of Point objects
Type:
The approximated length of the curve.
Read only.
 Number
Type:
The area that the curve’s geometry is covering.
Read only.
 Number
Type:
Bounding Boxes
The bounding rectangle of the curve including stroke width.
 Rectangle
Type:
The bounding rectangle of the curve including handles.
 Rectangle
Type:
Methods
 String — a string representation of the curve
Returns:
Determines the type of cubic Bézier curve via discriminant classification, as well as the curvetime parameters of the associated points of inflection, loops, cusps, etc.
 Object — the curve classification information as an object, see options
Returns:
 info.type: String — the type of Bézier curve, possible values are: ‘line’, ‘quadratic’, ‘serpentine’, ‘cusp’, ‘loop’, ‘arch’
 info.roots: Array of Numbers — the curvetime parameters of the associated points of inflection for serpentine curves, loops, cusps, etc
Removes the curve from the path that it belongs to, by removing its second segment and merging its handle with the first segment.
 Boolean — true if the curve was removed, false otherwise
Returns:
Checks if the this is the first curve in the path.curves array.
 Boolean — true if this is the first curve, false otherwise
Returns:
Checks if the this is the last curve in the path.curves array.
 Boolean — true if this is the last curve, false otherwise
Returns:
Creates a new curve as a subcurve from this curve, its range defined by the given curvetime parameters. If from
is larger than to
, then the resulting curve will have its direction reversed.
 from: Number — the curvetime parameter at which the subcurve starts
 to: Number — the curvetime parameter at which the subcurve ends
Parameters:
 Curve — the newly create subcurve
Returns:
Divides the curve into two curves at the given offset or location. The curve itself is modified and becomes the first part, the second part is returned as a new curve. If the curve belongs to a path item, a new segment is inserted into the path at the given location, and the second part becomes a part of the path as well.
 location: Number⟋CurveLocation — the offset or location on the curve at which to divide
Parameters:
 Curve — the second part of the divided curve if the location is valid, {code null} otherwise
Returns:
 divideAtTime(time)
See also:
Divides the curve into two curves at the given curvetime parameter. The curve itself is modified and becomes the first part, the second part is returned as a new curve. If the modified curve belongs to a path item, the second part is also added to the path.
 time: Number — the curvetime parameter on the curve at which to divide
Parameters:
 Curve — the second part of the divided curve, if the offset is within the valid range, {code null} otherwise.
Returns:
 divideAt(offset)
See also:
Splits the path this curve belongs to at the given offset. After splitting, the path will be open. If the path was open already, splitting will result in two paths.
 location: Number⟋CurveLocation — the offset or location on the curve at which to split
Parameters:
 Path — the newly created path after splitting, if any
Returns:
 path.splitAt(offset)
See also:
Splits the path this curve belongs to at the given offset. After splitting, the path will be open. If the path was open already, splitting will result in two paths.
 time: Number — the curvetime parameter on the curve at which to split
Parameters:
 Path — the newly created path after splitting, if any
Returns:
 path.splitAt(offset)
See also:
Returns a reversed version of the curve, without modifying the curve itself.
 Curve — a reversed version of the curve
Returns:
Clears the curve’s handles by setting their coordinates to zero, turning the curve into a straight line.
Curve Tests
Checks if this curve has any curve handles set.
 Boolean — true if the curve has handles set, false otherwise
Returns:
 curve.handle1
 curve.handle2
 segment.hasHandles()
 path.hasHandles()
See also:
Checks if this curve has any length.
 epsilon: Number — the epsilon against which to compare the curve’s length — optional, default: 0
Parameters:
 Boolean — true if the curve is longer than the given epsilon, false otherwise
Returns:
Checks if this curve appears as a straight line. This can mean that it has no handles defined, or that the handles run collinear with the line that connects the curve’s start and end point, not falling outside of the line.
 Boolean — true if the curve is straight, false otherwise
Returns:
Checks if this curve is parametrically linear, meaning that it is straight and its handles are positioned at 1/3 and 2/3 of the total length of the curve.
 Boolean — true if the curve is parametrically linear, false otherwise
Returns:
Checks if the the two curves describe straight lines that are collinear, meaning they run in parallel.
 curve: Curve — the other curve to check against
Parameters:
 Boolean — true if the two lines are collinear, false otherwise
Returns:
Checks if the curve is a straight horizontal line.
 Boolean — true if the line is horizontal, false otherwise
Returns:
Checks if the curve is a straight vertical line.
 Boolean — true if the line is vertical, false otherwise
Returns:
Positions on Curves
Calculates the curve location at the specified offset on the curve.
 offset: Number — the offset on the curve
Parameters:
 CurveLocation — the curve location at the specified the offset
Returns:
Calculates the curve location at the specified curvetime parameter on the curve.
 time: Number — the curvetime parameter on the curve
Parameters:
 CurveLocation — the curve location at the specified the location
Returns:
Calculates the curvetime parameter of the specified offset on the path, relative to the provided start parameter. If offset is a negative value, the parameter is searched to the left of the start parameter. If no start parameter is provided, a default of 0
for positive values of offset
and 1
for negative values of offset
.
 offset: Number — the offset at which to find the curvetime, in curve length units
 start: Number — the curvetime in relation to which the offset is determined — optional
Parameters:
 Number — the curvetime parameter at the specified location
Returns:
Calculates the curve offset at the specified curvetime parameter on the curve.
 time: Number — the curvetime parameter on the curve
Parameters:
 Number — the curve offset at the specified the location
Returns:
Returns the curve location of the specified point if it lies on the curve, null
otherwise.
 point: Point — the point on the curve
Parameters:
 CurveLocation — the curve location of the specified point
Returns:
Returns the length of the path from its beginning up to up to the specified point if it lies on the path, null
otherwise.
 point: Point — the point on the path
Parameters:
 Number — the length of the path up to the specified point
Returns:
Returns the curvetime parameter of the specified point if it lies on the curve, null
otherwise. Note that if there is more than one possible solution in a selfintersecting curve, the first found result is returned.
 point: Point — the point on the curve
Parameters:
 Number — the curvetime parameter of the specified point
Returns:
Returns the nearest location on the curve to the specified point.
 point: Point — the point for which we search the nearest location
Parameters:
 CurveLocation — the location on the curve that’s the closest to the specified point
Returns:
Calculates the point on the curve at the given location.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Point — the point on the curve at the given location
Returns:
Calculates the normalized tangent vector of the curve at the given location.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Point — the normalized tangent of the curve at the given location
Returns:
Calculates the normal vector of the curve at the given location.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Point — the normal of the curve at the given location
Returns:
Calculates the weighted tangent vector of the curve at the given location, its length reflecting the curve velocity at that location.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Point — the weighted tangent of the curve at the given location
Returns:
Calculates the weighted normal vector of the curve at the given location, its length reflecting the curve velocity at that location.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Point — the weighted normal of the curve at the given location
Returns:
Calculates the curvature of the curve at the given location. Curvatures indicate how sharply a curve changes direction. A straight line has zero curvature, where as a circle has a constant curvature. The curve’s radius at the given location is the reciprocal value of its curvature.
 location: Number⟋CurveLocation — the offset or location on the curve
Parameters:
 Number — the curvature of the curve at the given location
Returns:
Calculates the point on the curve at the given location.
 time: Number — the curvetime parameter on the curve
Parameters:
 Point — the point on the curve at the given location
Returns:
Calculates the normalized tangent vector of the curve at the given location.
 time: Number — the curvetime parameter on the curve
Parameters:
 Point — the normalized tangent of the curve at the given location
Returns:
Calculates the normal vector of the curve at the given location.
 time: Number — the curvetime parameter on the curve
Parameters:
 Point — the normal of the curve at the given location
Returns:
Calculates the weighted tangent vector of the curve at the given location, its length reflecting the curve velocity at that location.
 time: Number — the curvetime parameter on the curve
Parameters:
 Point — the weighted tangent of the curve at the given location
Returns:
Calculates the weighted normal vector of the curve at the given location, its length reflecting the curve velocity at that location.
 time: Number — the curvetime parameter on the curve
Parameters:
 Point — the weighted normal of the curve at the given location
Returns:
Calculates the curvature of the curve at the given location. Curvatures indicate how sharply a curve changes direction. A straight line has zero curvature, where as a circle has a constant curvature. The curve’s radius at the given location is the reciprocal value of its curvature.
 time: Number — the curvetime parameter on the curve
Parameters:
 Number — the curvature of the curve at the given location
Returns:
Returns all intersections between two Curve objects as an array of CurveLocation objects.

curve:
Curve
— the other curve to find the intersections with (if the curve itself or
null
is passed, the self intersection of the curve is returned, if it exists)
Parameters:
 Array of CurveLocation objects — the locations of all intersections between the curves