Expansions
Expand or contract 2D and 3D geometries by a fixed offset distance. Useful for adding wall thickness, clearance gaps, or rounding edges uniformly.
See also:
expand
Section titled “expand”function expand( options: { delta?: number; corners?: 'round' | 'chamfer' | 'edge'; segments?: number }, geometry: Geom2 | Geom3 ): Geom2 | Geom3Expand (grow) or contract (shrink) a 2D or 3D geometry by a fixed delta.
Positive delta grows the geometry outward; negative delta shrinks it inward. Works on Geom2 and Geom3. For 3D geometries, corners are rounded by default.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
— | Expansion options. |
options.delta |
— | Offset distance. Positive = grow, negative = shrink. Default 0.1. |
options.corners |
— | Corner style: ‘round’, ‘chamfer’, or ‘edge’. Default ‘round’. |
options.segments |
— | Segments per rounded corner. Default 16. |
geometry |
— | The geometry to expand or contract. |
Returns: A new geometry expanded or contracted by the given delta.
const { square } = jscad.primitivesconst { expand } = jscad.expansionsasync function main() { return expand({ delta: 2, corners: 'round', segments: 32 }, square({ size: 10 }))}See also:
offset
Section titled “offset”function offset( options: { delta?: number; corners?: 'round' | 'chamfer' | 'edge'; segments?: number }, geometry: Geom2 | Path2 ): Geom2 | Path2Offset a 2D geometry or open path by a fixed delta along its outline.
Similar to expand, but works on Geom2 and Path2 (not Geom3). Positive delta moves the outline outward; negative moves it inward.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
— | Offset options. |
options.delta |
— | Offset distance. Positive = outward, negative = inward. Default 0.1. |
options.corners |
— | Corner style: ‘round’, ‘chamfer’, or ‘edge’. Default ‘edge’. |
options.segments |
— | Segments per rounded corner. Default 16. |
geometry |
— | A Geom2 or Path2 to offset. |
Returns: A new Geom2 or Path2 with its outline moved by delta.
const { rectangle } = jscad.primitivesconst { offset } = jscad.expansionsasync function main() { const inner = rectangle({ size: [10, 6] }) const outer = offset({ delta: 1.5 }, inner) return [inner, outer]}See also: