Divooka Reference

CAD 2D Shapes

25 nodes

On this page 25

Area

Function

A shape's area, in square model units.

Signature
Area(shape: Cad Shape) -> Number
double Area(CadShape shape)

Parameters

nametypedefaultdescription
shapeCad Shape—

Returns

resultNumber
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Bounds

Function

The box round a shape, flat at Z = 0.

Signature
Bounds(shape: Cad Shape) -> Bounding Box
BoundingBox Bounds(CadShape shape)

Parameters

nametypedefaultdescription
shapeCad Shape—

Returns

resultBounding Box
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Circle

Function

A disk centred on the origin, an exact circle; or, given three or more segments, OpenSCAD's regular polygon of that many corners on the circle, the first on +X: circle(r, $fn = segments).

Signature
Circle(radius: Number, segments: Integer) -> Cad Shape
CadShape Circle(double radius, int segments = 0)

Parameters

nametypedefaultdescription
radiusNumber—Its radius: the corners' distance from the middle when it has segments.
segmentsInteger0Zero for an exact circle, or the number of a polygon's corners (at least three).

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Difference

Function

A shape with every cutter taken away, OpenSCAD's difference() of 2D children: the first child less the others.

Signature
Difference -> Cad Shape
    shape: Cad Shape
    cutters: Cad Shape Array
    tolerance: Number
CadShape Difference(
    CadShape shape,
    CadShape[] cutters,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapeCad Shape—What is cut.
cuttersCad Shape Array—What cuts it.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Fill

Function

A shape without its holes, OpenSCAD's fill(): each region's outer boundary filled, islands in former holes merged in.

Signature
Fill(shape: Cad Shape, tolerance: Number) -> Cad Shape
CadShape Fill(CadShape shape, double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Fragments

Function

How many segments OpenSCAD cuts a circle of a radius into, from its special variables: $fn when it is set, else as many as keep each segment's angle at least Minimum Angle and its length at least Minimum Size, and never fewer than five. Give the count to Cad2D.Circle, Cad.Frustum and the other round operations to reproduce a model that relies on OpenSCAD's facets; leave it out for exact circles.

Signature
Fragments -> Integer
    radius: Number
    fn: Integer
    minimumAngle: Number
    minimumSize: Number
int Fragments(
    double radius,
    int fn = 0,
    double minimumAngle = 0.20943951023931953,
    double minimumSize = 2)

Parameters

nametypedefaultdescription
radiusNumber—The circle's radius.
fnInteger0OpenSCAD's $fn: zero when not set.
minimumAngleNumber0.20943951023931953OpenSCAD's $fa, in radians: 12° unless set.
minimumSizeNumber2OpenSCAD's $fs, in model units: 2 unless set.

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

From Curves

Function

The shape closed curves in the XY plane enclose: even-odd by default, as polygon paths are, so curves inside others are holes; nonzero reads which way each curve runs, as font outlines and most SVG paths do; any fills everything inside any curve.

Signature
FromCurves -> Cad Shape
    boundaries: Curve Array
    fill: Curve Fill Rule
    tolerance: Number
CadShape FromCurves(
    Curve[] boundaries,
    CurveFillRule fill = CurveFillRule.EvenOdd,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
boundariesCurve Array—Closed curves lying in the XY plane.
fillCurve Fill RuleEven oddWhich points they enclose.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

From Regions

Function

The shape of planar regions in the XY plane - what CadCurves.BooleanRegions and CadText.Regions give - merged where they overlap.

Signature
FromRegions -> Cad Shape
    regions: Curve Region Array
    tolerance: Number
CadShape FromRegions(
    CurveRegion[] regions,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
regionsCurve Region Array—The regions, each an outer boundary with holes.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Hull

Function

The convex hull of flat shapes, OpenSCAD's hull() of 2D children: the smallest convex shape holding them all. Exact for lines and arcs - the hull of circles is their arcs and the lines tangent to two of them - and within the tolerance for other curves, which are first followed by tangent arcs.

Signature
Hull(shapes: Cad Shape Array, tolerance: Number) -> Cad Shape
CadShape Hull(CadShape[] shapes, double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapesCad Shape Array—The shapes.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape

Remarks

Built by turning a direction once round and following, for each, the piece of the shapes furthest along it: a corner, or a stretch of an arc whose outward normal it is; where the furthest piece changes, the hull runs straight from one to the next along the line touching both.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Hull Of Points

Function

The convex hull of points in the XY plane, as a flat shape; their Z is ignored. Fewer than three points not in a line hold no area and give an empty shape.

Signature
HullOfPoints -> Cad Shape
    points: Point3d Array
    tolerance: Number
CadShape HullOfPoints(
    Point3d[] points,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
pointsPoint3d Array—The points.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Intersection

Function

What every shape has in common, OpenSCAD's intersection() of 2D children. An empty list gives an empty shape.

Signature
Intersection -> Cad Shape
    shapes: Cad Shape Array
    tolerance: Number
CadShape Intersection(
    CadShape[] shapes,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapesCad Shape Array—The shapes.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Minkowski

Function

The Minkowski sum of flat shapes, OpenSCAD's minkowski() of 2D children: every point of one added to every point of the next. Exact where one of two shapes is a circle (the other offset by its radius, as OpenSCAD's rounded rectangle is), or one is made of lines and the other is convex; otherwise the shapes' arcs are followed by lines within the tolerance first.

Signature
Minkowski -> Cad Shape
    shapes: Cad Shape Array
    tolerance: Number
CadShape Minkowski(CadShape[] shapes, double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapesCad Shape Array—The shapes, summed in turn.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape

Remarks

A shape of lines A plus a convex shape B is A moved by a point of B together with, for each line of A's boundary, the hull of B at its two ends; a shape of lines that is not convex is cut into trapezoids, which are.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Mirror

Function

A shape mirrored in the line through the origin square to a direction, OpenSCAD's mirror([x, y]): (1, 0) mirrors left to right.

Signature
Mirror -> Cad Shape
    shape: Cad Shape
    normalX: Number
    normalY: Number
CadShape Mirror(CadShape shape, double normalX, double normalY)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
normalXNumber—The mirror line's normal, along X.
normalYNumber—The mirror line's normal, along Y.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Offset

Function

A shape grown or shrunk by a distance with round corners, OpenSCAD's offset(r): growing, every point within the radius of the shape joins it (its Minkowski sum with a disk); shrinking, every point within the radius of its outside leaves it. Boundaries of lines and arcs give exact lines and arcs; other curves are first followed within the tolerance by tangent-continuous arcs.

Signature
Offset -> Cad Shape
    shape: Cad Shape
    radius: Number
    tolerance: Number
CadShape Offset(
    CadShape shape,
    double radius,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
radiusNumber—How far, in model units: positive grows, negative shrinks.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape

Remarks

Every boundary is offset whole, exactly: each line and arc moved out (or in) by the distance - an arc tighter than that through its middle and out the other side - with an arc round each corner. Those curves hold every edge of the result but may cross themselves and each other; the plane they cut up is kept face by face where a point inside the face is in the shape or within the distance of it (growing), or in the shape and no nearer its edge than the distance (shrinking). Narrow gaps close and thin parts vanish as they should.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Offset Delta

Function

A shape grown or shrunk by a distance with sharp corners, OpenSCAD's offset(delta, chamfer): every boundary moves out (or in) square to itself, and corners are carried out to where the moved sides meet, or with Chamfer cut straight across. Sides of lines and arcs stay exact; at a corner of an arc the moved sides are met along their tangents.

Signature
OffsetDelta -> Cad Shape
    shape: Cad Shape
    delta: Number
    chamfer: Truth
    tolerance: Number
CadShape OffsetDelta(
    CadShape shape,
    double delta,
    bool chamfer = false,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
deltaNumber—How far, in model units: positive grows, negative shrinks.
chamferTruthFalseCut the corners across rather than carrying them to a point.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape

Remarks

Every boundary is offset whole, its corners carried out (or cut) on the side the offset opens and joined straight across where the offset sides cross; the plane those curves cut up is kept face by face where they wind round it positively, as Clipper fills a mitred offset, so the loops a concave corner throws out of a growing shape, and the reversed ones of a shrinking shape's vanished parts, are left out.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Outlines

Function

Copies of every boundary of a shape: each region's outer boundary, then its holes.

Signature
Outlines(shape: Cad Shape) -> Curve Array
Curve[] Outlines(CadShape shape)

Parameters

nametypedefaultdescription
shapeCad Shape—

Returns

resultCurve Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Polygon

Function

A polygon through points, OpenSCAD's polygon(points, paths): with no paths, one boundary through every point in order; with paths, one boundary through each list of point indices. The boundaries are filled even-odd, so a path inside another is a hole, and one inside that an island, whichever way each runs; a boundary that crosses itself fills alternately.

Signature
Polygon -> Cad Shape
    points: Point3d Array
    paths: Integer Array Array
    tolerance: Number
CadShape Polygon(
    Point3d[] points,
    int[][] paths,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
pointsPoint3d Array—The points; only X and Y are read.
pathsInteger Array Array—Lists of indices into Points, one a boundary; null for one boundary through every point.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Resize

Function

A shape scaled about the origin to a width and height, OpenSCAD's resize([x, y], auto): a size of zero keeps that direction as it is, or, with Auto, scales it by the largest factor of the sizes given, keeping the proportions.

Signature
Resize -> Cad Shape
    shape: Cad Shape
    width: Number
    height: Number
    auto: Truth
CadShape Resize(
    CadShape shape,
    double width,
    double height,
    bool auto = false)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
widthNumber—The new width along X; zero to leave it.
heightNumber—The new height along Y; zero to leave it.
autoTruthFalseScale the directions given zero with the others.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Rotate

Function

A shape turned about a point, counter-clockwise seen from +Z, OpenSCAD's rotate(a) about the origin (whose angle is in degrees).

Signature
Rotate -> Cad Shape
    shape: Cad Shape
    angle: Number
    centerX: Number
    centerY: Number
CadShape Rotate(
    CadShape shape,
    double angle,
    double centerX = 0,
    double centerY = 0)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
angleNumber—How far, in radians.
centerXNumber0The point it turns about, along X.
centerYNumber0The point it turns about, along Y.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Scale

Function

A shape scaled about the origin, OpenSCAD's scale([x, y]). A negative factor mirrors it.

Signature
Scale(shape: Cad Shape, x: Number, y: Number) -> Cad Shape
CadShape Scale(CadShape shape, double x, double y)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
xNumber—The factor along X.
yNumber—The factor along Y.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Square

Function

A rectangle with a corner at the origin, or centred on it: OpenSCAD's square([width, height], center).

Signature
Square -> Cad Shape
    width: Number
    height: Number
    centered: Truth
CadShape Square(
    double width,
    double height,
    bool centered = false)

Parameters

nametypedefaultdescription
widthNumber—Along X.
heightNumber—Along Y.
centeredTruthFalseCentred on the origin rather than cornered on it.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Text

Function

Text as a flat shape, OpenSCAD's text(text, size, font, halign, valign): the font's exact outlines, counters as holes, laid out from the origin along +X with lines going down. Size is the em height in model units (OpenSCAD's size is close to the cap height instead). The alignments stand the outline's box on the origin; laid out as is, the text starts at the origin on its first baseline.

Signature
Text -> Cad Shape
    text: Text
    font: Cad Font
    size: Number
    horizontal: Cad Text Horizontal
    vertical: Cad Text Vertical
    tolerance: Number
CadShape Text(
    string text,
    CadFont font,
    double size,
    CadTextHorizontal horizontal = CadTextHorizontal.Left,
    CadTextVertical vertical = CadTextVertical.Baseline,
    double tolerance = 1E-06)

Parameters

nametypedefaultdescription
textText—The text; newlines start new lines.
fontCad Font—The font, captured beforehand (Parametric.CadFonts).
sizeNumber—The em height, in model units.
horizontalCad Text HorizontalLeftWhere the text stands across the origin.
verticalCad Text VerticalBaselineWhere the text stands up and down the origin.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Transformed

Function

A shape under a transform that keeps the XY plane where it is, OpenSCAD's multmatrix of a 2D child: any invertible mix of moves, turns, scales, mirrors and shears within the plane.

Signature
Transformed(shape: Cad Shape, transform: Transform) -> Cad Shape
CadShape Transformed(CadShape shape, Transform transform)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
transformTransform—The transform; it must take the XY plane to itself.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Translate

Function

A shape moved, OpenSCAD's translate([x, y]).

Signature
Translate(shape: Cad Shape, x: Number, y: Number) -> Cad Shape
CadShape Translate(CadShape shape, double x, double y)

Parameters

nametypedefaultdescription
shapeCad Shape—The shape.
xNumber—How far along X.
yNumber—How far along Y.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD

Union

Function

Everything in any of the shapes, OpenSCAD's union() of 2D children. An empty list gives an empty shape.

Signature
Union(shapes: Cad Shape Array, tolerance: Number) -> Cad Shape
CadShape Union(CadShape[] shapes, double tolerance = 1E-06)

Parameters

nametypedefaultdescription
shapesCad Shape Array—The shapes.
toleranceNumber1E-06The model's tolerance, in its units.

Returns

resultCad Shape
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
CAD 2D Shapes
Package
CAD