Skip to main content

expansions

modeling/expansions

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

modeling/expansions.expand(options, ...objects)

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.

Kind: static method of modeling/expansions
Returns: ObjectArray - new geometry, or list of new geometries

ParamTypeDefaultDescription
optionsObjectoptions for expand
[options.delta]Number1delta (+/-) of expansion
[options.corners]String'edge'type of corner to create after expanding; edge, chamfer, round
[options.segments]Integer16number of segments when creating round corners
...objectsObjectsthe geometries to expand

Example

let newarc = expand({delta: 5, corners: 'edge'}, arc({}))
let newsquare = expand({delta: 5, corners: 'chamfer'}, square({size: 30}))
let newcuboid = expand({delta: 2, corners: 'round'}, cuboid({size: [20, 25, 5]}))

modeling/expansions.offset(options, ...objects)

Create offset geometry from the given geometry using the given options. Offsets from internal and external space are created.

Kind: static method of modeling/expansions
Returns: ObjectArray - new geometry, or list of new geometries

ParamTypeDefaultDescription
optionsObjectoptions for offset
[options.delta]Float1delta of offset (+ to exterior, - from interior)
[options.corners]String'edge'type of corner to create after offseting; edge, chamfer, round
[options.segments]Integer16number of segments when creating round corners
...objectsObjectthe geometries to offset

Example

let small = offset({ delta: -4, corners: 'chamfer' }, square({size: 40})) // contract