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)
})
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).centered()
offset(-10, true)
})
Closing an open offset
Chaining .close() connects the offset back to the original profile with two
straight cap edges, producing a closed loop you can extrude or fill:
import { arc, offset, sketch } from "fluidcad/core";
sketch("xy", () => {
arc([50, 100]);
offset(10).close()
})
For profiles that are already closed (e.g. a circle or a closed rectangle),
.close() is a no-op. Combining .close() with removeOriginal=true throws,
since there is no original profile left to cap to.
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
})