All shapes (primitives or the results of operations) can be expanded (or contracted.) In all cases, the function returns the results, and never changes the original shapes.
Example
const { expand, offset } = require('@jscad/modeling').expansions
Methods
(static) expand(options, …objects) → {Object|Array}
Expand the given geometry using the given options. Both internal and external space is expanded for 2D and 3D shapes.
Note: Contract is expand using a negative delta.
Example
let newarc = expand({delta: 5, corners: 'edge'}, arc({}))
let newsquare = expand({delta: 5, corners: 'chamfer'}, square({size: 30}))
let newsphere = expand({delta: 2, corners: 'round'}, cuboid({size: [20, 25, 5]}))
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for expand Properties
|
|||||||||||||||||||||
objects |
Objects |
<repeatable> |
the geometries to expand |
Returns:
new geometry, or list of new geometries
- Type
- Object | Array
(static) offset(options, …objects) → {Object|Array}
Create offset geometry from the given geometry using the given options. Offsets from internal and external space are created.
Example
let small = offset({ delta: -4, corners: 'chamfer' }, square({size: 40})) // contract
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | options for offset Properties
|
|||||||||||||||||||||
objects |
Object |
<repeatable> |
the geometries to offset |
Returns:
new geometry, or list of new geometries
- Type
- Object | Array