Skip to main content

Offset

offset() creates a copy of sketch geometry shifted inward or outward by a given distance.

Basic usage

Inside a sketch, offset() offsets all existing shapes:

import { sketch, offset } from 'fluidcad/core';
import { rect } from 'fluidcad/core';

sketch("xy", () => {
rect(50)
offset(5)
})

Offset outward

Positive values offset outward, negative values offset inward.

Removing the original

Pass true as the second argument to remove the original geometry and keep only the offset:

import { sketch, offset } from 'fluidcad/core';
import { rect } from 'fluidcad/core';

sketch("xy", () => {
rect(100, 60).center()
offset(-10, true)
})

Offset inward with removal

Combining with other shapes

Offset is useful for creating walls, margins, and clearances:

sketch("xy", () => {
rect(50)
circle(30)
offset(5) // both the rect and circle are offset
circle(14) // add another shape after offsetting
})