Class: CAG

CAG

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.
Source:

Methods

(static) circle(optionsopt) → {CAG}

Construct a circle.
Parameters:
Name Type Attributes Description
options Object <optional>
options for construction
Properties
Name Type Attributes Default Description
center Vector2D <optional>
[0,0] center of circle
radius Number <optional>
1 radius of circle
resolution Number <optional>
CSG.defaultResolution2D number of sides per 360 rotation
Source:
Returns:
new CAG object
Type
CAG

(static) ellipse(optionsopt) → {CAG}

Construct a ellispe.
Parameters:
Name Type Attributes Description
options Object <optional>
options for construction
Properties
Name Type Attributes Default Description
center Vector2D <optional>
[0,0] center of ellipse
radius Vector2D <optional>
[1,1] radius of ellipse, width and height
resolution Number <optional>
CSG.defaultResolution2D number of sides per 360 rotation
Source:
Returns:
new CAG object
Type
CAG

(static) fromCompactBinary(bin) → {CAG}

Reconstruct a CAG from the output of toCompactBinary().
Parameters:
Name Type Description
bin CompactBinary see toCompactBinary()
Source:
Returns:
new CAG object
Type
CAG

(static) fromObject(obj) → {CAG}

Reconstruct a CAG from an object with identical property names.
Parameters:
Name Type Description
obj Object anonymous object, typically from JSON
Source:
Returns:
new CAG object
Type
CAG

(static) fromPoints(points) → {CAG}

Construct a CAG from a list of points (a polygon). 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.
Parameters:
Name Type Description
points Array.<points> list of points in 2D space
Source:
Returns:
new CAG object
Type
CAG

(static) fromSides(sides) → {CAG}

Construct a CAG from a list of `CAG.Side` instances.
Parameters:
Name Type Description
sides Array.<CAG.Side> list of sides
Source:
Returns:
new CAG object
Type
CAG

(static) rectangle(optionsopt) → {CAG}

Construct a rectangle.
Parameters:
Name Type Attributes Description
options Object <optional>
options for construction
Properties
Name Type Attributes Default Description
center Vector2D <optional>
[0,0] center of rectangle
radius Vector2D <optional>
[1,1] radius of rectangle, width and height
corner1 Vector2D <optional>
[0,0] bottom left corner of rectangle (alternate)
corner2 Vector2D <optional>
[0,0] upper right corner of rectangle (alternate)
Source:
Returns:
new CAG object
Type
CAG

(static) roundedRectangle(optionsopt) → {CAG}

Construct a rounded rectangle.
Parameters:
Name Type Attributes Description
options Object <optional>
options for construction
Properties
Name Type Attributes Default Description
center Vector2D <optional>
[0,0] center of rounded rectangle
radius Vector2D <optional>
[1,1] radius of rounded rectangle, width and height
corner1 Vector2D <optional>
[0,0] bottom left corner of rounded rectangle (alternate)
corner2 Vector2D <optional>
[0,0] upper right corner of rounded rectangle (alternate)
roundradius Number <optional>
0.2 round radius of corners
resolution Number <optional>
CSG.defaultResolution2D number of sides per 360 rotation
Source:
Returns:
new CAG object
Type
CAG
Example
var r = CSG.roundedRectangle({
  center: [0, 0],
  radius: [5, 10],
  roundradius: 2,
  resolution: 36,
});

rotateExtrude(options) → {CSG}

Extrude to into a 3D solid by rotating the origin around the Y axis. (and turning everything into XY plane)
Parameters:
Name Type Description
options Object options for construction
Properties
Name Type Attributes Default Description
angle Number <optional>
360 angle of rotation
resolution Number <optional>
CSG.defaultResolution3D number of polygons per 360 degree revolution
Source:
Returns:
new 3D solid
Type
CSG

toCompactBinary() → {CompactBinary}

Convert to compact binary form. See CAG.fromCompactBinary.
Source:
Returns:
Type
CompactBinary