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.

Source:
Example
const { expand, offset } = require('@jscad/modeling').expansions

Methods

(static) expand(options, …geometry) → {Object|Array}

Source:

Expand the given geometry using the given options. 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
Name Type Attributes Default Description
delta Number <optional>
1

delta (+/-) of expansion

corners String <optional>
'edge'

type of corner to create after expanding; edge, chamfer, round

segments Integer <optional>
16

number of segments when creating round corners

geometry Objects <repeatable>

the list of geometry to expand

Returns:

new geometry, or list of new geometries

Type
Object | Array

(static) offset(options, …geometry) → {Object|Array}

Source:

Create offset geometry from the given geometry using the given options.

Example
let small = offset({ delta: -4, corners: 'chamfer' }, square({size: 40})) // contract
Parameters:
Name Type Attributes Description
options Object

options for offset

Properties
Name Type Attributes Default Description
delta Float <optional>
1

delta of offset (+ to exterior, - from interior)

corners String <optional>
'edge'

type of corner to create after offseting; edge, chamfer, round

segments Integer <optional>
16

number of segments when creating round corners

geometry Object <repeatable>

the list of geometry to offset

Returns:

new geometry, or list of new geometries

Type
Object | Array