Autodesk Creative Platform Core Version 1.19.0
A broad and deep collection of 2D and 3D capabilities.

Path2D Overview
2D paths are vector shapes on a 2D plane, such as the graphic objects you would find in a vectorbased graphics program like Adobe Illustrator. They can be extruded to create 3D shapes using the Solid.extrude() function. The Path2D API is equivalent to the HTML5 Canvas API's methods for creating paths. Create an object that represents a 2D path. Call this constructor with JavaScript's standard new keyword: new Path2D() By default, the path is empty. Add line and curve segments to the path using the methods described below.See Also: Bezier2D, Line2D
Introduced in Version: 1.0.0
Class Member Summary
 Path2D ( JSON ) 
 methodbezierCurveTo ( Number , Number , Number , Number , Number , Number ) 
 methodclone ( )
 methodclose ( ) 
 methodcurveAt ( Number )
 methodcurvesByPoint ( Point2D , Number )
 methodfirstCurve ( )
 methodlastCurve ( )
 methodlineTo ( Number , Number ) 
 methodmoveTo ( Number , Number ) 
 methodquadraticCurveTo ( Number , Number , Number , Number ) 
 methodtoJSON ( ) 
 methodtoPolygons ( Number )
 methodtransform ( Matrix2D or Array [ Number ] ) 
Class Member Details
• Path2D ([json]) 
The following parameters can be specified in the constructor:
 json: JSON  JSON received from the toJSON method. Throws exception if JSON not valid. 
• Path2D bezierCurveTo (cp1x, cp1y, cp2x, cp2y, x, y) 
Creates a cubic Bézier curve from the path's current point to the point (x, y),
with two control points at (cp1x, cp1y) and (cp2x, cp2y) that control the curvature
of the resulting curve. After adding the line, sets the path's current point to this line's end point.
• Path2D clone()
Clones the Path2D object
• Path2D close() 
Closes the path by creating a line segment from the path's current point to the start point of the path.
• Line2D or Bezier2D curveAt (idx)
Constructs the curve at the given index
 idx: Number  the index of curve
• Array [ Line2D or Bezier2D ] curvesByPoint (point, tolerance)
Returns a collection of curves whose distances to the given point is less than tolerance.
If the given point is close to a control point of a Bezier curve, the Bezier curve will be selected too.
The result curves are sorted on the distance to the given point from farthest to closest
• Line2D or Bezier2D firstCurve()
Gets the first curve of the path
• Line2D or Bezier2D lastCurve()
Gets the last curve of the path
• Path2D lineTo (x, y) 
Creates a straight line from the path's current point to the point (x, y).
After adding the line, sets the path's current point to the line's end point.
• Path2D moveTo (x, y) 
Sets the path's current point to the point (x, y).
The current point is used by a path's linedrawing methods
as the starting point for each added line segment. By default,
the current point of a newly created path lies at (0, 0).
• Path2D quadraticCurveTo (cpx, cpy, x, y) 
Creates a quadratic Bézier curve from the path's current point to the point (x, y),
with a control point at (cpx, cpy) that controls the curvature of the resulting curve.
After adding the line, sets the path's current point to this line's end point.
• JSON toJSON() 
Returns the JSON repressentation of the object that can be serialized.
The resulting JSON can be passed into the constuctor later on to reconstruct the object.
• Array [ Array [ Number ] ] toPolygons ([tolerance])
Gets an array of connected path outlines. If the first and last points are the same then the path is closed.
 tolerance: Number  A chord height deviation to use for discretizing nonlinear curves. 
1 Example:
// Iterate the polygons generated from the path2d var polygons = path2DObj.toPolygons(); for (var i = 0; i < polygons.length; i++) { var polygon = polygons[i]; for (var j = 0; j < polygon.length; j+=2) { var x = polygon[j]; var y = polygon[j+1]; ... } }
• Path2D transform (matrix) 
Transforms the geometry on the path by a transformation matrix.
2 Examples:
// Scale to 2X and translation by 5, 5 var tm = [ 2, 0, 0, 0, 2, 0, 5, 5, 1 ]; path.transform(tm);
// Scale to 2X and translation by 5, 5 var tm = new Matrix2D(); tm.identity().scaling(2).translation(5, 5); path.transform(tm);