Skip to main content

offset_shape

Function offset_shape 

Source
pub fn offset_shape(
    sp: &SPolygon,
    mode: ShapeModifyMode,
    distance: f32,
) -> Result<SPolygon>
Expand description

Offsets a SPolygon by a certain distance either inwards or outwards depending on the ShapeModifyMode. Uses [geo::Buffer] to resolve intersections in the offset boundary.

The buffer is computed in f64 and can contain zero-width spikes or pinches, for example where a slit is exactly twice the distance wide (see issue #130). Rounding it back to f32 can make such a boundary self-intersect. In that case, the offset is retried with a slightly larger distance, which still yields a superset (inflate) or subset (deflate) of the original shape.