## Classes
CAG
CSG
## Constants
defaultResolution2D

Number of polygons per 360 degree revolution for 2D objects.

defaultResolution3D

Number of polygons per 360 degree revolution for 3D objects.

EPS

Epsilon used during determination of near zero distances.

angleEPS

Epsilon used during determination of near zero areas.

areaEPS

Epsilon used during determination of near zero areas. This is the minimal area of a minimal polygon.

## Functions
center([options], objects)Object | Array

Centers the given object(s) using the given options (if any)

clone(obj)CSG

clone the given object

css2rgb(String)

Converts an CSS color name to RGB color.

color(color, objects)CSG

apply the given color to the input object(s)

rgb2hsl(Number, Number, Number)

Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and l in the set [0, 1].

hsl2rgb(Number, Number, Number)

Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 1].

rgb2hsv(Number, Number, Number)

Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and v in the set [0, 1].

hsv2rgb(Number, Number, Number)

Converts an HSV color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1] and returns r, g, and b in the set [0, 1].

html2rgb()

Converts a HTML5 color value (string) to RGB values See the color input type of HTML5 forms Conversion formula:

rgb2html()

Converts RGB color value to HTML5 color value (string) Conversion forumla:

union(objects)CSG

union/ combine the given shapes

difference(objects)CSG

difference/ subtraction of the given shapes ie: cut out C From B From A ie : a - b - c etc

intersection(objects)CSG

intersection of the given shapes: ie keep only the common parts between the given shapes

overCutInsideCorners(_cag, cutterradius)CAG

cag = cag.overCutInsideCorners(cutterradius); Using a CNC router it's impossible to cut out a true sharp inside corner. The inside corner will be rounded due to the radius of the cutter. This function compensates for this by creating an extra cutout at each inner corner so that the actual cut out shape will be at least as large as needed.

sectionCut(csg, orthobasis)

cuts a csg along a orthobasis

cutByPlane(plane)CSG

Cut the solid by a plane. Returns the solid on the back side of the plane

expandedShellOfCCSG(radius, resolution, unionWithThis)

Create the expanded shell of the solid: All faces are extruded to get a thickness of 2*radius Cylinders are constructed around every side Spheres are placed on every vertex unionWithThis: if true, the resulting solid will be united with 'this' solid; the result is a true expansion of the solid If false, returns only the shell

extrudeInOrthonormalBasis(cag, orthonormalbasis, depth, [options])

extrude the CAG in a certain plane. Giving just a plane is not enough, multiple different extrusions in the same plane would be possible by rotating around the plane's origin. An additional right-hand vector should be specified as well, and this is exactly a OrthoNormalBasis.

extrudeInPlane(cag, axis1, axis2, depth, [options])

Extrude in a standard cartesian plane, specified by two axis identifiers. Each identifier can be one of ["X","Y","Z","-X","-Y","-Z"] The 2d x axis will map to the first given 3D axis, the 2d y axis will map to the second. See OrthoNormalBasis.GetCartesian for details.

extrude(cag, [options])CSG

linear extrusion of 2D shape, with optional twist

rotateExtrude(options)CSG

Extrude to into a 3D solid by rotating the origin around the Y axis. (and turning everything into XY plane)

linear_extrude([options], baseShape)CSG

linear extrusion of the input 2d shape

rotate_extrude([options], baseShape)CSG

rotate extrusion / revolve of the given 2d shape

rectangular_extrude(basePoints, [options])CSG

rectangular extrusion of the given array of points

translate(vector, ...objects)CSG

translate an object in 2D/3D space

scale(scale, ...objects)CSG

scale an object in 2D/3D space

rotate(rotation, objects)CSG

rotate an object in 2D/3D space

transform(matrix, ...objects)CSG

apply the given matrix transform to the given objects

center(axes, ...object)CSG

Center the given object(s) about the given axes

mirror(vector, ...objects)CSG

mirror an object in 2D/3D space

expand(radius, object)CSG/CAG

expand an object in 2D/3D space

contract(radius, object)CSG/CAG

contract an object(s) in 2D/3D space

minkowski(objects)CSG

create a minkowski sum of the given shapes

hull(objects)CSG

create a convex hull of the given shapes

chain_hull(objects)CSG

create a chain hull of the given shapes Originally "Whosa whatsis" suggested "Chain Hull" , as described at https://plus.google.com/u/0/105535247347788377245/posts/aZGXKFX1ACN essentially hull A+B, B+C, C+D and then union those

square([options])CAG

Construct a square/rectangle

circle([options])CAG

Construct a circle

polygon([options])CAG

Construct a polygon either from arrays of paths and points, or just arrays of points nested paths (multiple paths) and flat paths are supported

triangle()CAG

Construct a triangle

circle([options])CAG

Construct a circle.

ellipse([options])CAG

Construct an ellispe.

rectangle([options])CAG

Construct a rectangle.

roundedRectangle([options])CAG

Construct a rounded rectangle.

cube([options])CSG

Construct a cuboid

sphere([options])CSG

Construct a sphere

cylinder([options])CSG

Construct a cylinder

torus([options])CSG

Construct a torus

polyhedron([options])CSG

Construct a polyhedron from the given triangles/ polygons/points

cube([options])CSG

Construct an axis-aligned solid cuboid.

sphere([options])CSG

Construct a solid sphere

cylinder([options])CSG

Construct a solid cylinder.

roundedCylinder([options])CSG

Construct a cylinder with rounded ends.

cylinderElliptic([options])CSG

Construct an elliptic cylinder.

roundedCube([options])CSG

Construct an axis-aligned solid rounded cuboid.

polyhedron([options])CSG

Create a polyhedron using Openscad style arguments. Define face vertices clockwise looking from outside.

solidFromSlices(options)

Creates solid from slices (Polygon) by generating walls

_addWalls(walls, bottom, top)
vectorChar([options], [char])VectorCharObject

Construct a VectorCharObject from a ascii character whose code is between 31 and 127, if the character is not supported it is replaced by a question mark.

vectorText([options], [text])Array

Construct an array of character segments from a ascii string whose characters code is between 31 and 127, if one character is not supported it is replaced by a question mark.

vector_char(x, y, char)VectorCharObject

Construct a VectorCharObject from a ascii character whose code is between 31 and 127, if the character is not supported it is replaced by a question mark.

vector_text(x, y, text)Array

Construct an array of character segments from a ascii string whose characters code is between 31 and 127, if one character is not supported it is replaced by a question mark.

fromSides(sides)CAG

Construct a CAG from a list of Side instances.

fromPoints(points)CAG

Construct a CAG from a list of points (a polygon) or an nested array of points. The rotation direction of the points is not relevant. The points can define a convex or a concave polygon. The polygon must not self intersect. Hole detection follows the even/odd rule, which means that the order of the paths is not important.

fromObject(obj)CAG

Reconstruct a CAG from an object with identical property names.

fromPointsNoCheck(points)CAG

Construct a CAG from a list of points (a polygon). Like fromPoints() but does not check if the result is a valid polygon. The points MUST rotate counter clockwise. The points can define a convex or a concave polygon. The polygon must not self intersect.

fromPath2(Path2)CAG

Construct a CAG from a 2d-path (a closed sequence of points). Like fromPoints() but does not check if the result is a valid polygon.

fromCompactBinary(bin)CAG

Reconstruct a CAG from the output of toCompactBinary().

fromPolygons(polygons)CSG

Construct a CSG solid from a list of Polygon instances.

fromSlices(options)CSG

Construct a CSG solid from a list of pre-generated slices. See Polygon.prototype.solidFromSlices() for details.

fromObject(obj)CSG

Reconstruct a CSG solid from an object with identical property names.

fromCompactBinary(bin)CSG

Reconstruct a CSG from the output of toCompactBinary().

## Typedefs
VectorCharObject : Object

Represents a character as segments

## CAG **Kind**: global class * [CAG](#CAG) * [new CAG()](#new_CAG_new) * [.toPoints()](#CAG+toPoints) ⇒ Array.<points> * [.toCompactBinary()](#CAG+toCompactBinary) ⇒ CompactBinary ### new CAG() Class CAG Holds a solid area geometry like CSG but 2D. Each area consists of a number of sides. Each side is a line between 2 points. ### caG.toPoints() ⇒ Array.<points> Convert to a list of points. **Kind**: instance method of [CAG](#CAG) **Returns**: Array.<points> - list of points in 2D space ### caG.toCompactBinary() ⇒ CompactBinary Convert to compact binary form. See fromCompactBinary. **Kind**: instance method of [CAG](#CAG) ## CSG **Kind**: global class * [CSG](#CSG) * [new CSG()](#new_CSG_new) * [.union(csg)](#CSG+union) ⇒ [CSG](#CSG) * [.subtract(csg)](#CSG+subtract) ⇒ [CSG](#CSG) * [.intersect(csg)](#CSG+intersect) ⇒ [CSG](#CSG) * [.invert()](#CSG+invert) ⇒ [CSG](#CSG) * [.transform(matrix4x4)](#CSG+transform) ⇒ [CSG](#CSG) * [.mayOverlap(csg)](#CSG+mayOverlap) * [.connectTo(myConnector, otherConnector, mirror, normalrotation)](#CSG+connectTo) ⇒ [CSG](#CSG) * [.setShared(shared)](#CSG+setShared) ⇒ [CSG](#CSG) * [.setColor(args)](#CSG+setColor) ⇒ [CSG](#CSG) * [.getFeatures(features)](#CSG+getFeatures) ⇒ Array.<Float> * [.toPolygons()](#CSG+toPolygons) ⇒ Array.<Polygon> * [.toCompactBinary()](#CSG+toCompactBinary) ⇒ Object * [.toTriangles()](#CSG+toTriangles) ⇒ Polygons ### new CSG() Class CSG Holds a binary space partition tree representing a 3D solid. Two solids can be combined using the `union()`, `subtract()`, and `intersect()` methods. ### csG.union(csg) ⇒ [CSG](#CSG) Return a new CSG solid representing the space in either this solid or in the given solids. Neither this solid nor the given solids are modified. **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | csg | [Array.<CSG>](#CSG) | list of CSG objects | **Example** ```js let C = A.union(B) ``` **Example** ```js +-------+ +-------+ | | | | | A | | | | +--+----+ = | +----+ +----+--+ | +----+ | | B | | | | | | | +-------+ +-------+ ``` ### csG.subtract(csg) ⇒ [CSG](#CSG) Return a new CSG solid representing space in this solid but not in the given solids. Neither this solid nor the given solids are modified. **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | csg | [Array.<CSG>](#CSG) | list of CSG objects | **Example** ```js let C = A.subtract(B) ``` **Example** ```js +-------+ +-------+ | | | | | A | | | | +--+----+ = | +--+ +----+--+ | +----+ | B | | | +-------+ ``` ### csG.intersect(csg) ⇒ [CSG](#CSG) Return a new CSG solid representing space in both this solid and in the given solids. Neither this solid nor the given solids are modified. **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | csg | [Array.<CSG>](#CSG) | list of CSG objects | **Example** ```js let C = A.intersect(B) ``` **Example** ```js +-------+ | | | A | | +--+----+ = +--+ +----+--+ | +--+ | B | | | +-------+ ``` ### csG.invert() ⇒ [CSG](#CSG) Return a new CSG solid with solid and empty space switched. This solid is not modified. **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - new CSG object **Example** ```js let B = A.invert() ``` ### csG.transform(matrix4x4) ⇒ [CSG](#CSG) Return a new CSG solid that is transformed using the given Matrix. Several matrix transformations can be combined before transforming this solid. **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | matrix4x4 | CSG.Matrix4x4 | matrix to be applied | **Example** ```js var m = new CSG.Matrix4x4() m = m.multiply(CSG.Matrix4x4.rotationX(40)) m = m.multiply(CSG.Matrix4x4.translation([-.5, 0, 0])) let B = A.transform(m) ``` ### csG.mayOverlap(csg) returns true if there is a possibility that the two solids overlap returns false if we can be sure that they do not overlap NOTE: this is critical as it is used in UNIONs **Kind**: instance method of [CSG](#CSG) | Param | Type | | --- | --- | | csg | [CSG](#CSG) | ### csG.connectTo(myConnector, otherConnector, mirror, normalrotation) ⇒ [CSG](#CSG) Connect a solid to another solid, such that two Connectors become connected **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - this csg, tranformed accordingly | Param | Type | Description | | --- | --- | --- | | myConnector | Connector | a Connector of this solid | | otherConnector | Connector | a Connector to which myConnector should be connected | | mirror | Boolean | false: the 'axis' vectors of the connectors should point in the same direction true: the 'axis' vectors of the connectors should point in opposite direction | | normalrotation | Float | degrees of rotation between the 'normal' vectors of the two connectors | ### csG.setShared(shared) ⇒ [CSG](#CSG) set the .shared property of all polygons **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - Returns a new CSG solid, the original is unmodified! | Param | Type | | --- | --- | | shared | Object | ### csG.setColor(args) ⇒ [CSG](#CSG) sets the color of this csg: non mutating, returns a new CSG **Kind**: instance method of [CSG](#CSG) **Returns**: [CSG](#CSG) - a copy of this CSG, with the given color | Param | Type | | --- | --- | | args | Object | ### csG.getFeatures(features) ⇒ Array.<Float> Returns an array of values for the requested features of this solid. Supported Features: 'volume', 'area' **Kind**: instance method of [CSG](#CSG) **Returns**: Array.<Float> - values | Param | Type | Description | | --- | --- | --- | | features | Array.<String> | list of features to calculate | **Example** ```js let volume = A.getFeatures('volume') let values = A.getFeatures('area','volume') ``` ### csG.toPolygons() ⇒ Array.<Polygon> **Kind**: instance method of [CSG](#CSG) **Returns**: Array.<Polygon> - The list of polygons. ### csG.toCompactBinary() ⇒ Object returns a compact binary representation of this csg usually used to transfer CSG objects to/from webworkes NOTE: very interesting compact format, with a lot of reusable ideas **Kind**: instance method of [CSG](#CSG) **Returns**: Object - compact binary representation of a CSG ### csG.toTriangles() ⇒ Polygons returns the triangles of this csg **Kind**: instance method of [CSG](#CSG) **Returns**: Polygons - triangulated polygons ## defaultResolution2D Number of polygons per 360 degree revolution for 2D objects. **Kind**: global constant **Default**: 32 ## defaultResolution3D Number of polygons per 360 degree revolution for 3D objects. **Kind**: global constant **Default**: 12 ## EPS Epsilon used during determination of near zero distances. **Kind**: global constant **Default**: 0.00001 ## angleEPS Epsilon used during determination of near zero areas. **Kind**: global constant **Default**: 0.1 ## areaEPS Epsilon used during determination of near zero areas. This is the minimal area of a minimal polygon. **Kind**: global constant ## center([options], objects) ⇒ Object \| Array Centers the given object(s) using the given options (if any) **Kind**: global function **Returns**: Object \| Array - objects | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for centering | | [options.axes] | Array | [true,true,true] | axis of which to center, true or false | | [options.center] | Array | [0,0,0] | point of which to center the object upon | | objects | Object \| Array | | the shape(s) to center | **Example** ```js let csg = center({axes: [true,false,false]}, sphere()) // center about the X axis ``` ## clone(obj) ⇒ [CSG](#CSG) clone the given object **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , a copy of the input | Param | Type | Description | | --- | --- | --- | | obj | Object | the object to clone by | **Example** ```js let copy = clone(sphere()) ``` ## css2rgb(String) ⇒ Converts an CSS color name to RGB color. **Kind**: global function **Returns**: Array The RGB representation, or [0,0,0] default | Param | Description | | --- | --- | | String | s The CSS color name | ## color(color, objects) ⇒ [CSG](#CSG) apply the given color to the input object(s) **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , with the given color | Param | Type | Description | | --- | --- | --- | | color | Object | either an array or a hex string of color values | | objects | Object \| Array | either a single or multiple CSG/CAG objects to color | **Example** ```js let redSphere = color([1,0,0,1], sphere()) ``` ## rgb2hsl(Number, Number, Number) ⇒ Converts an RGB color value to HSL. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and l in the set [0, 1]. **Kind**: global function **Returns**: Array The HSL representation | Param | Description | | --- | --- | | Number | r The red color value | | Number | g The green color value | | Number | b The blue color value | ## hsl2rgb(Number, Number, Number) ⇒ Converts an HSL color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are contained in the set [0, 1] and returns r, g, and b in the set [0, 1]. **Kind**: global function **Returns**: Array The RGB representation | Param | Description | | --- | --- | | Number | h The hue | | Number | s The saturation | | Number | l The lightness | ## rgb2hsv(Number, Number, Number) ⇒ Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and v in the set [0, 1]. **Kind**: global function **Returns**: Array The HSV representation | Param | Description | | --- | --- | | Number | r The red color value | | Number | g The green color value | | Number | b The blue color value | ## hsv2rgb(Number, Number, Number) ⇒ Converts an HSV color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1] and returns r, g, and b in the set [0, 1]. **Kind**: global function **Returns**: Array The RGB representation | Param | Description | | --- | --- | | Number | h The hue | | Number | s The saturation | | Number | v The value | ## html2rgb() Converts a HTML5 color value (string) to RGB values See the color input type of HTML5 forms Conversion formula: - split the string; "#RRGGBB" into RGB components - convert the HEX value into RGB values **Kind**: global function ## rgb2html() Converts RGB color value to HTML5 color value (string) Conversion forumla: - convert R, G, B into HEX strings - return HTML formatted string "#RRGGBB" **Kind**: global function ## union(objects) ⇒ [CSG](#CSG) union/ combine the given shapes **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object, the union of all input shapes | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | objects to combine : can be given - one by one: union(a,b,c) or - as an array: union([a,b,c]) | **Example** ```js let unionOfSpherAndCube = union(sphere(), cube()) ``` ## difference(objects) ⇒ [CSG](#CSG) difference/ subtraction of the given shapes ie: cut out C From B From A ie : a - b - c etc **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object, the difference of all input shapes | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | objects to subtract can be given - one by one: difference(a,b,c) or - as an array: difference([a,b,c]) | **Example** ```js let differenceOfSpherAndCube = difference(sphere(), cube()) ``` ## intersection(objects) ⇒ [CSG](#CSG) intersection of the given shapes: ie keep only the common parts between the given shapes **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object, the intersection of all input shapes | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | objects to intersect can be given - one by one: intersection(a,b,c) or - as an array: intersection([a,b,c]) | **Example** ```js let intersectionOfSpherAndCube = intersection(sphere(), cube()) ``` ## overCutInsideCorners(_cag, cutterradius) ⇒ [CAG](#CAG) cag = cag.overCutInsideCorners(cutterradius); Using a CNC router it's impossible to cut out a true sharp inside corner. The inside corner will be rounded due to the radius of the cutter. This function compensates for this by creating an extra cutout at each inner corner so that the actual cut out shape will be at least as large as needed. **Kind**: global function **Returns**: [CAG](#CAG) - cag with overcutInsideCorners | Param | Type | Description | | --- | --- | --- | | _cag | Object | input cag | | cutterradius | Float | radius to cut inside corners by | ## sectionCut(csg, orthobasis) cuts a csg along a orthobasis **Kind**: global function | Param | Type | Description | | --- | --- | --- | | csg | [CSG](#CSG) | the csg object to cut | | orthobasis | Orthobasis | the orthobasis to cut along | ## cutByPlane(plane) ⇒ [CSG](#CSG) Cut the solid by a plane. Returns the solid on the back side of the plane **Kind**: global function **Returns**: [CSG](#CSG) - the solid on the back side of the plane | Param | Type | | --- | --- | | plane | Plane | ## expandedShellOfCCSG(radius, resolution, unionWithThis) Create the expanded shell of the solid: All faces are extruded to get a thickness of 2*radius Cylinders are constructed around every side Spheres are placed on every vertex unionWithThis: if true, the resulting solid will be united with 'this' solid; the result is a true expansion of the solid If false, returns only the shell **Kind**: global function | Param | Type | | --- | --- | | radius | Float | | resolution | Integer | | unionWithThis | Boolean | ## extrudeInOrthonormalBasis(cag, orthonormalbasis, depth, [options]) extrude the CAG in a certain plane. Giving just a plane is not enough, multiple different extrusions in the same plane would be possible by rotating around the plane's origin. An additional right-hand vector should be specified as well, and this is exactly a OrthoNormalBasis. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | cag | [CAG](#CAG) | | the cag to extrude | | orthonormalbasis | Orthonormalbasis | | characterizes the plane in which to extrude | | depth | Float | | thickness of the extruded shape. Extrusion is done upwards from the plane (unless symmetrical option is set, see below) | | [options] | Object | | options for construction | | [options.symmetrical] | Boolean | true | extrude symmetrically in two directions about the plane | ## extrudeInPlane(cag, axis1, axis2, depth, [options]) Extrude in a standard cartesian plane, specified by two axis identifiers. Each identifier can be one of ["X","Y","Z","-X","-Y","-Z"] The 2d x axis will map to the first given 3D axis, the 2d y axis will map to the second. See OrthoNormalBasis.GetCartesian for details. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | cag | [CAG](#CAG) | | the cag to extrude | | axis1 | String | | the first axis | | axis2 | String | | the second axis | | depth | Float | | thickness of the extruded shape. Extrusion is done upwards from the plane | | [options] | Object | | options for construction | | [options.symmetrical] | Boolean | true | extrude symmetrically in two directions about the plane | ## extrude(cag, [options]) ⇒ [CSG](#CSG) linear extrusion of 2D shape, with optional twist **Kind**: global function **Returns**: [CSG](#CSG) - the extrude shape, as a CSG object | Param | Type | Default | Description | | --- | --- | --- | --- | | cag | [CAG](#CAG) | | the cag to extrude | | [options] | Object | | options for construction | | [options.offset] | Array | [0,0,1] | The 2d shape is placed in in z=0 plane and extruded into direction (a 3D vector as a 3 component array) | | [options.twiststeps] | Boolean | defaultResolution3D | twiststeps determines the resolution of the twist (should be >= 1) | | [options.twistangle] | Boolean | 0 | twistangle The final face is rotated degrees. Rotation is done around the origin of the 2d shape (i.e. x=0, y=0) | **Example** ```js extruded=cag.extrude({offset: [0,0,10], twistangle: 360, twiststeps: 100}); ``` ## rotateExtrude(options) ⇒ [CSG](#CSG) Extrude to into a 3D solid by rotating the origin around the Y axis. (and turning everything into XY plane) **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | options for construction | | [options.angle] | Number | 360 | angle of rotation | | [options.resolution] | Number | defaultResolution3D | number of polygons per 360 degree revolution | ## linear_extrude([options], baseShape) ⇒ [CSG](#CSG) linear extrusion of the input 2d shape **Kind**: global function **Returns**: [CSG](#CSG) - new extruded shape | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.height] | Float | 1 | height of the extruded shape | | [options.slices] | Integer | 10 | number of intermediary steps/slices | | [options.twist] | Integer | 0 | angle (in degrees to twist the extusion by) | | [options.center] | Boolean | false | whether to center extrusion or not | | baseShape | [CAG](#CAG) | | input 2d shape | **Example** ```js let revolved = linear_extrude({height: 10}, square()) ``` ## rotate_extrude([options], baseShape) ⇒ [CSG](#CSG) rotate extrusion / revolve of the given 2d shape **Kind**: global function **Returns**: [CSG](#CSG) - new extruded shape | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.fn] | Integer | 1 | resolution/number of segments of the extrusion | | [options.startAngle] | Float | 1 | start angle of the extrusion, in degrees | | [options.angle] | Float | 1 | angle of the extrusion, in degrees | | [options.overflow] | Float | 'cap' | what to do with points outside of bounds (+ / - x) : defaults to capping those points to 0 (only supported behaviour for now) | | baseShape | [CAG](#CAG) | | input 2d shape | **Example** ```js let revolved = rotate_extrude({fn: 10}, square()) ``` ## rectangular_extrude(basePoints, [options]) ⇒ [CSG](#CSG) rectangular extrusion of the given array of points **Kind**: global function **Returns**: [CSG](#CSG) - new extruded shape | Param | Type | Default | Description | | --- | --- | --- | --- | | basePoints | Array | | array of points (nested) to extrude from layed out like [ [0,0], [10,0], [5,10], [0,10] ] | | [options] | Object | | options for construction | | [options.h] | Float | 1 | height of the extruded shape | | [options.w] | Float | 10 | width of the extruded shape | | [options.fn] | Integer | 1 | resolution/number of segments of the extrusion | | [options.closed] | Boolean | false | whether to close the input path for the extrusion or not | | [options.round] | Boolean | true | whether to round the extrusion or not | **Example** ```js let revolved = rectangular_extrude({height: 10}, square()) ``` ## translate(vector, ...objects) ⇒ [CSG](#CSG) translate an object in 2D/3D space **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , translated by the given amount | Param | Type | Description | | --- | --- | --- | | vector | Object | 3D vector to translate the given object(s) by | | ...objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to translate | **Example** ```js let movedSphere = translate([10,2,0], sphere()) ``` ## scale(scale, ...objects) ⇒ [CSG](#CSG) scale an object in 2D/3D space **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , scaled by the given amount | Param | Type | Description | | --- | --- | --- | | scale | Float \| Array | either an array or simple number to scale object(s) by | | ...objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to scale | **Example** ```js let scaledSphere = scale([0.2,15,1], sphere()) ``` ## rotate(rotation, objects) ⇒ [CSG](#CSG) rotate an object in 2D/3D space **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , rotated by the given amount | Param | Type | Description | | --- | --- | --- | | rotation | Float \| Array | either an array or simple number to rotate object(s) by | | objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to rotate | **Example** ```js let rotatedSphere = rotate([0.2,15,1], sphere()) ``` ## transform(matrix, ...objects) ⇒ [CSG](#CSG) apply the given matrix transform to the given objects **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , transformed | Param | Type | Description | | --- | --- | --- | | matrix | Array | the 4x4 matrix to apply, as a simple 1d array of 16 elements | | ...objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to transform | **Example** ```js const angle = 45 let transformedShape = transform([ cos(angle), -sin(angle), 0, 10, sin(angle), cos(angle), 0, 20, 0 , 0, 1, 30, 0, 0, 0, 1 ], sphere()) ``` ## center(axes, ...object) ⇒ [CSG](#CSG) Center the given object(s) about the given axes **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , translated by the given amount | Param | Type | Default | Description | | --- | --- | --- | --- | | axes | Array \| Boolean | [true,true,true]|true | an array of boolean values that indicate the axes (X,Y,Z) to center upon. A single boolean is also allowed. | | ...object | Object | | one or more objects to center, i.e. objects are CSG or CAG | **Example** ```js let csg = center([true,false,false], sphere()) // center about the X axis ``` ## mirror(vector, ...objects) ⇒ [CSG](#CSG) mirror an object in 2D/3D space **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , mirrored | Param | Type | Description | | --- | --- | --- | | vector | Array | the axes to mirror the object(s) by | | ...objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to mirror | **Example** ```js let rotatedSphere = mirror([0.2,15,1], sphere()) ``` ## expand(radius, object) ⇒ CSG/CAG expand an object in 2D/3D space **Kind**: global function **Returns**: CSG/CAG - new CSG/CAG object , expanded | Param | Type | Description | | --- | --- | --- | | radius | float | the radius to expand by | | object | Object | a CSG/CAG objects to expand | **Example** ```js let expanededShape = expand([0.2,15,1], sphere()) ``` ## contract(radius, object) ⇒ CSG/CAG contract an object(s) in 2D/3D space **Kind**: global function **Returns**: CSG/CAG - new CSG/CAG object , contracted | Param | Type | Description | | --- | --- | --- | | radius | float | the radius to contract by | | object | Object | a CSG/CAG objects to contract | **Example** ```js let contractedShape = contract([0.2,15,1], sphere()) ``` ## minkowski(objects) ⇒ [CSG](#CSG) create a minkowski sum of the given shapes **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , mirrored | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to create a hull around | **Example** ```js let hulled = hull(rect(), circle()) ``` ## hull(objects) ⇒ [CSG](#CSG) create a convex hull of the given shapes **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object , a hull around the given shapes | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to create a hull around | **Example** ```js let hulled = hull(rect(), circle()) ``` ## chain_hull(objects) ⇒ [CSG](#CSG) create a chain hull of the given shapes Originally "Whosa whatsis" suggested "Chain Hull" , as described at https://plus.google.com/u/0/105535247347788377245/posts/aZGXKFX1ACN essentially hull A+B, B+C, C+D and then union those **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object ,which a chain hull of the inputs | Param | Type | Description | | --- | --- | --- | | objects | Object(s) \| Array | either a single or multiple CSG/CAG objects to create a chain hull around | **Example** ```js let hulled = chain_hull(rect(), circle()) ``` ## square([options]) ⇒ [CAG](#CAG) Construct a square/rectangle **Kind**: global function **Returns**: [CAG](#CAG) - new square | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.size] | Float | 1 | size of the square, either as array or scalar | | [options.center] | Boolean | true | wether to center the square/rectangle or not | **Example** ```js let square1 = square({ size: 10 }) ``` ## circle([options]) ⇒ [CAG](#CAG) Construct a circle **Kind**: global function **Returns**: [CAG](#CAG) - new circle | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.r] | Float | 1 | radius of the circle | | [options.fn] | Integer | 32 | segments of circle (ie quality/ resolution) | | [options.center] | Boolean | true | wether to center the circle or not | **Example** ```js let circle1 = circle({ r: 10 }) ``` ## polygon([options]) ⇒ [CAG](#CAG) Construct a polygon either from arrays of paths and points, or just arrays of points nested paths (multiple paths) and flat paths are supported **Kind**: global function **Returns**: [CAG](#CAG) - new polygon | Param | Type | Description | | --- | --- | --- | | [options] | Object | options for construction or either flat or nested array of points | | [options.points] | Array | points of the polygon : either flat or nested array of points | | [options.paths] | Array | paths of the polygon : either flat or nested array of points index | **Example** ```js let roof = [[10,11], [0,11], [5,20]] let wall = [[0,0], [10,0], [10,10], [0,10]] let poly = polygon(roof) or let poly = polygon([roof, wall]) or let poly = polygon({ points: roof }) or let poly = polygon({ points: [roof, wall] }) or let poly = polygon({ points: roof, path: [0, 1, 2] }) or let poly = polygon({ points: [roof, wall], path: [[0, 1, 2], [3, 4, 5, 6]] }) or let poly = polygon({ points: roof.concat(wall), paths: [[0, 1, 2], [3, 4, 5], [3, 6, 5]] }) ``` ## triangle() ⇒ [CAG](#CAG) Construct a triangle **Kind**: global function **Returns**: [CAG](#CAG) - new triangle **Example** ```js let triangle = trangle({ length: 10 }) ``` ## circle([options]) ⇒ [CAG](#CAG) Construct a circle. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector2D | [0,0] | center of circle | | [options.radius] | Number | 1 | radius of circle | | [options.resolution] | Number | defaultResolution2D | number of sides per 360 rotation | ## ellipse([options]) ⇒ [CAG](#CAG) Construct an ellispe. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector2D | [0,0] | center of ellipse | | [options.radius] | Vector2D | [1,1] | radius of ellipse, width and height | | [options.resolution] | Number | defaultResolution2D | number of sides per 360 rotation | ## rectangle([options]) ⇒ [CAG](#CAG) Construct a rectangle. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector2D | [0,0] | center of rectangle | | [options.radius] | Vector2D | [1,1] | radius of rectangle, width and height | | [options.corner1] | Vector2D | [0,0] | bottom left corner of rectangle (alternate) | | [options.corner2] | Vector2D | [0,0] | upper right corner of rectangle (alternate) | ## roundedRectangle([options]) ⇒ [CAG](#CAG) Construct a rounded rectangle. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector2D | [0,0] | center of rounded rectangle | | [options.radius] | Vector2D | [1,1] | radius of rounded rectangle, width and height | | [options.corner1] | Vector2D | [0,0] | bottom left corner of rounded rectangle (alternate) | | [options.corner2] | Vector2D | [0,0] | upper right corner of rounded rectangle (alternate) | | [options.roundradius] | Number | 0.2 | round radius of corners | | [options.resolution] | Number | defaultResolution2D | number of sides per 360 rotation | **Example** ```js let r = roundedRectangle({ center: [0, 0], radius: [5, 10], roundradius: 2, resolution: 36, }); ``` ## cube([options]) ⇒ [CSG](#CSG) Construct a cuboid **Kind**: global function **Returns**: [CSG](#CSG) - new sphere | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.size] | Float | 1 | size of the side of the cuboid : can be either: - a scalar : ie a single float, in which case all dimensions will be the same - or an array: to specify different dimensions along x/y/z | | [options.fn] | Integer | 32 | segments of the sphere (ie quality/resolution) | | [options.fno] | Integer | 32 | segments of extrusion (ie quality) | | [options.type] | String | 'normal' | type of sphere : either 'normal' or 'geodesic' | **Example** ```js let cube1 = cube({ r: 10, fn: 20 }) ``` ## sphere([options]) ⇒ [CSG](#CSG) Construct a sphere **Kind**: global function **Returns**: [CSG](#CSG) - new sphere | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.r] | Float | 1 | radius of the sphere | | [options.fn] | Integer | 32 | segments of the sphere (ie quality/resolution) | | [options.fno] | Integer | 32 | segments of extrusion (ie quality) | | [options.type] | String | 'normal' | type of sphere : either 'normal' or 'geodesic' | **Example** ```js let sphere1 = sphere({ r: 10, fn: 20 }) ``` ## cylinder([options]) ⇒ [CSG](#CSG) Construct a cylinder **Kind**: global function **Returns**: [CSG](#CSG) - new cylinder | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.r] | Float | 1 | radius of the cylinder | | [options.r1] | Float | 1 | radius of the top of the cylinder | | [options.r2] | Float | 1 | radius of the bottom of the cylinder | | [options.d] | Float | 1 | diameter of the cylinder | | [options.d1] | Float | 1 | diameter of the top of the cylinder | | [options.d2] | Float | 1 | diameter of the bottom of the cylinder | | [options.fn] | Integer | 32 | number of sides of the cylinder (ie quality/resolution) | **Example** ```js let cylinder = cylinder({ d: 10, fn: 20 }) ``` ## torus([options]) ⇒ [CSG](#CSG) Construct a torus **Kind**: global function **Returns**: [CSG](#CSG) - new torus | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.ri] | Float | 1 | radius of base circle | | [options.ro] | Float | 4 | radius offset | | [options.fni] | Integer | 16 | segments of base circle (ie quality) | | [options.fno] | Integer | 32 | segments of extrusion (ie quality) | | [options.roti] | Integer | 0 | rotation angle of base circle | **Example** ```js let torus1 = torus({ ri: 10 }) ``` ## polyhedron([options]) ⇒ [CSG](#CSG) Construct a polyhedron from the given triangles/ polygons/points **Kind**: global function **Returns**: [CSG](#CSG) - new polyhedron | Param | Type | Description | | --- | --- | --- | | [options] | Object | options for construction | | [options.triangles] | Array | triangles to build the polyhedron from | | [options.polygons] | Array | polygons to build the polyhedron from | | [options.points] | Array | points to build the polyhedron from | | [options.colors] | Array | colors to apply to the polyhedron | **Example** ```js let torus1 = polyhedron({ points: [...] }) ``` ## cube([options]) ⇒ [CSG](#CSG) Construct an axis-aligned solid cuboid. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector3 | [0,0,0] | center of cube | | [options.radius] | Vector3 | [1,1,1] | radius of cube, single scalar also possible | **Example** ```js let cube = CSG.cube({ center: [5, 5, 5], radius: 5, // scalar radius }); ``` ## sphere([options]) ⇒ [CSG](#CSG) Construct a solid sphere **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector3 | [0,0,0] | center of sphere | | [options.radius] | Number | 1 | radius of sphere | | [options.resolution] | Number | defaultResolution3D | number of polygons per 360 degree revolution | | [options.axes] | Array | | an array with 3 vectors for the x, y and z base vectors | **Example** ```js let sphere = CSG.sphere({ center: [0, 0, 0], radius: 2, resolution: 32, }); ``` ## cylinder([options]) ⇒ [CSG](#CSG) Construct a solid cylinder. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.start] | Vector | [0,-1,0] | start point of cylinder | | [options.end] | Vector | [0,1,0] | end point of cylinder | | [options.radius] | Number | 1 | radius of cylinder, must be scalar | | [options.resolution] | Number | defaultResolution3D | number of polygons per 360 degree revolution | **Example** ```js let cylinder = CSG.cylinder({ start: [0, -10, 0], end: [0, 10, 0], radius: 10, resolution: 16 }); ``` ## roundedCylinder([options]) ⇒ [CSG](#CSG) Construct a cylinder with rounded ends. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.start] | Vector3 | [0,-1,0] | start point of cylinder | | [options.end] | Vector3 | [0,1,0] | end point of cylinder | | [options.radius] | Number | 1 | radius of rounded ends, must be scalar | | [options.normal] | Vector3 | | vector determining the starting angle for tesselation. Should be non-parallel to start.minus(end) | | [options.resolution] | Number | defaultResolution3D | number of polygons per 360 degree revolution | **Example** ```js let cylinder = CSG.roundedCylinder({ start: [0, -10, 0], end: [0, 10, 0], radius: 2, resolution: 16 }); ``` ## cylinderElliptic([options]) ⇒ [CSG](#CSG) Construct an elliptic cylinder. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.start] | Vector3 | [0,-1,0] | start point of cylinder | | [options.end] | Vector3 | [0,1,0] | end point of cylinder | | [options.radius] | Vector2D | [1,1] | radius of rounded ends, must be two dimensional array | | [options.radiusStart] | Vector2D | [1,1] | OPTIONAL radius of rounded start, must be two dimensional array | | [options.radiusEnd] | Vector2D | [1,1] | OPTIONAL radius of rounded end, must be two dimensional array | | [options.resolution] | Number | defaultResolution2D | number of polygons per 360 degree revolution | **Example** ```js let cylinder = CSG.cylinderElliptic({ start: [0, -10, 0], end: [0, 10, 0], radiusStart: [10,5], radiusEnd: [8,3], resolution: 16 }); ``` ## roundedCube([options]) ⇒ [CSG](#CSG) Construct an axis-aligned solid rounded cuboid. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object | | options for construction | | [options.center] | Vector3 | [0,0,0] | center of rounded cube | | [options.radius] | Vector3 | [1,1,1] | radius of rounded cube, single scalar is possible | | [options.roundradius] | Number | 0.2 | radius of rounded edges | | [options.resolution] | Number | defaultResolution3D | number of polygons per 360 degree revolution | **Example** ```js let cube = CSG.roundedCube({ center: [2, 0, 2], radius: 15, roundradius: 2, resolution: 36, }); ``` ## polyhedron([options]) ⇒ [CSG](#CSG) Create a polyhedron using Openscad style arguments. Define face vertices clockwise looking from outside. **Kind**: global function **Returns**: [CSG](#CSG) - new 3D solid | Param | Type | Description | | --- | --- | --- | | [options] | Object | options for construction | ## solidFromSlices(options) Creates solid from slices (Polygon) by generating walls **Kind**: global function | Param | Type | Description | | --- | --- | --- | | options | Object | Solid generating options - numslices {Number} Number of slices to be generated - callback(t, slice) {Function} Callback function generating slices. arguments: t = [0..1], slice = [0..numslices - 1] return: Polygon or null to skip - loop {Boolean} no flats, only walls, it's used to generate solids like a tor | ## _addWalls(walls, bottom, top) **Kind**: global function | Param | Description | | --- | --- | | walls | Array of wall polygons | | bottom | Bottom polygon | | top | Top polygon | ## vectorChar([options], [char]) ⇒ [VectorCharObject](#VectorCharObject) Construct a [VectorCharObject](#VectorCharObject) from a ascii character whose code is between 31 and 127, if the character is not supported it is replaced by a question mark. **Kind**: global function | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object \| String | | options for construction or ascii character | | [options.xOffset] | Float | 0 | x offset | | [options.yOffset] | Float | 0 | y offset | | [options.height] | Float | 21 | font size (uppercase height) | | [options.extrudeOffset] | Float | 0 | width of the extrusion that will be applied (manually) after the creation of the character | | [options.input] | String | '?' | ascii character (ignored/overwrited if provided as seconds parameter) | | [char] | String | '?' | ascii character | **Example** ```js let vectorCharObject = vectorChar() or let vectorCharObject = vectorChar('A') or let vectorCharObject = vectorChar({ xOffset: 57 }, 'C') or let vectorCharObject = vectorChar({ xOffset: 78, input: '!' }) ``` ## vectorText([options], [text]) ⇒ Array Construct an array of character segments from a ascii string whose characters code is between 31 and 127, if one character is not supported it is replaced by a question mark. **Kind**: global function **Returns**: Array - characters segments [[[x, y], ...], ...] | Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | Object \| String | | options for construction or ascii string | | [options.xOffset] | Float | 0 | x offset | | [options.yOffset] | Float | 0 | y offset | | [options.height] | Float | 21 | font size (uppercase height) | | [options.lineSpacing] | Float | 1.4 | line spacing expressed as a percentage of font size | | [options.letterSpacing] | Float | 1 | extra letter spacing expressed as a percentage of font size | | [options.align] | String | 'left' | multi-line text alignement: left, center or right | | [options.extrudeOffset] | Float | 0 | width of the extrusion that will be applied (manually) after the creation of the character | | [options.input] | String | '?' | ascii string (ignored/overwrited if provided as seconds parameter) | | [text] | String | '?' | ascii string | **Example** ```js let textSegments = vectorText() or let textSegments = vectorText('OpenJSCAD') or let textSegments = vectorText({ yOffset: -50 }, 'OpenJSCAD') or let textSegments = vectorText({ yOffset: -80, input: 'OpenJSCAD' }) ``` ## ~~vector_char(x, y, char) ⇒ [VectorCharObject](#VectorCharObject)~~ ***Deprecated*** Construct a [VectorCharObject](#VectorCharObject) from a ascii character whose code is between 31 and 127, if the character is not supported it is replaced by a question mark. **Kind**: global function | Param | Type | Description | | --- | --- | --- | | x | Float | x offset | | y | Float | y offset | | char | String | ascii character | **Example** ```js let vectorCharObject = vector_char(36, 0, 'B') ``` ## ~~vector_text(x, y, text) ⇒ Array~~ ***Deprecated*** Construct an array of character segments from a ascii string whose characters code is between 31 and 127, if one character is not supported it is replaced by a question mark. **Kind**: global function **Returns**: Array - characters segments [[[x, y], ...], ...] | Param | Type | Description | | --- | --- | --- | | x | Float | x offset | | y | Float | y offset | | text | String | ascii string | **Example** ```js let textSegments = vector_text(0, -20, 'OpenJSCAD') ``` ## fromSides(sides) ⇒ [CAG](#CAG) Construct a CAG from a list of `Side` instances. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | sides | Array.<Side> | list of sides | ## fromPoints(points) ⇒ [CAG](#CAG) Construct a CAG from a list of points (a polygon) or an nested array of points. The rotation direction of the points is not relevant. The points can define a convex or a concave polygon. The polygon must not self intersect. Hole detection follows the even/odd rule, which means that the order of the paths is not important. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | points | Array.<points> \| Array.<Array.<points>> | (nested) list of points in 2D space | ## fromObject(obj) ⇒ [CAG](#CAG) Reconstruct a CAG from an object with identical property names. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | obj | Object | anonymous object, typically from JSON | ## fromPointsNoCheck(points) ⇒ [CAG](#CAG) Construct a CAG from a list of points (a polygon). Like fromPoints() but does not check if the result is a valid polygon. The points MUST rotate counter clockwise. The points can define a convex or a concave polygon. The polygon must not self intersect. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | points | Array.<points> | list of points in 2D space | ## fromPath2(Path2) ⇒ [CAG](#CAG) Construct a CAG from a 2d-path (a closed sequence of points). Like fromPoints() but does not check if the result is a valid polygon. **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | Path2 | path | a Path2 path | ## fromCompactBinary(bin) ⇒ [CAG](#CAG) Reconstruct a CAG from the output of toCompactBinary(). **Kind**: global function **Returns**: [CAG](#CAG) - new CAG object | Param | Type | Description | | --- | --- | --- | | bin | CompactBinary | see toCompactBinary() | ## fromPolygons(polygons) ⇒ [CSG](#CSG) Construct a CSG solid from a list of `Polygon` instances. **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | polygons | Array.<Polygon> | list of polygons | ## fromSlices(options) ⇒ [CSG](#CSG) Construct a CSG solid from a list of pre-generated slices. See Polygon.prototype.solidFromSlices() for details. **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | options | Object | options passed to solidFromSlices() | ## fromObject(obj) ⇒ [CSG](#CSG) Reconstruct a CSG solid from an object with identical property names. **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | obj | Object | anonymous object, typically from JSON | ## fromCompactBinary(bin) ⇒ [CSG](#CSG) Reconstruct a CSG from the output of toCompactBinary(). **Kind**: global function **Returns**: [CSG](#CSG) - new CSG object | Param | Type | Description | | --- | --- | --- | | bin | CompactBinary | see toCompactBinary(). | ## VectorCharObject : Object Represents a character as segments **Kind**: global typedef **Properties** | Name | Type | Description | | --- | --- | --- | | width | Float | character width | | height | Float | character height (uppercase) | | segments | Array | character segments [[[x, y], ...], ...] |