User Tools


This is an old revision of the document!


Path

A path is a series of points, connected by very thin (invisible) lines. In addition, a path can be open or closed. A closed path has a line between first and last points.

Paths can be created by giving an array of points, or by calling various functions to create or extend a path.

Note: The difference between Paths and 2D shapes are that Paths are composed of very thin lines, whereas a two dimensional shapes always enclose an area.

Which include:

arc(endpoint, options): return a circular or ellipsoid curved path (see example below for usage).

appendPoint([x,y]): create and return a new Path containing the callee's points followed by the given point.

appendPoints( 55}. Paths can be concatenated with .concat(), the result is a new path. Paths can be converted to two dimensional shapes. First, a Path can be converted directly to a two dimensional shape. But the Path must be closed. <code javascript> let path = new CSG.Path2D([[10,10], [-10,10], [-10,-10, true) create a closed path let shape = path.innerToCAG() </code> expandToCAG(pathradius, resolution) traces the path with a circle, in effect making the path's line segments thick. Creating a 3D solid is currently supported by the rectangularExtrude() function. This creates a 3D shape by following the path with a 2D rectangle (upright, perpendicular to the path direction): <code javascript> var path = new CSG.Path2D([ [10,10], [-10,10] ], /* closed = */ false); var anotherpath = new CSG.Path2D([ [-10,-10] ]); path = path.concat(anotherpath); path = path.appendPoint([10,-10]); path = path.close(); close the path

of course we could simply have done: var path = new CSG.Path2D([ [10,10], [-10,10], [-10,-10], [10,-10] ], /* closed = */ true);

We can make arcs and circles: var curvedpath = CSG.Path2D.arc({ center: [0,0,0], radius: 10, startangle: 0, endangle: 180, resolution: 16, }); </code>