@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
43 lines • 1.35 kB
TypeScript
import type { MultiFn2 } from "@thi.ng/defmulti";
import type { IShape } from "./api.js";
import type { AABB } from "./api/aabb.js";
import { Circle } from "./api/circle.js";
import type { Line } from "./api/line.js";
import { Quad } from "./api/quad.js";
import type { Rect } from "./api/rect.js";
/**
* Function overrides for {@link offset}.
*/
export type OffsetFn = {
(shape: AABB, dist: number): AABB;
(shape: Circle, dist: number): Circle;
(shape: Line, dist: number): Quad;
(shape: Rect, dist: number): Rect;
} & MultiFn2<IShape, number, IShape>;
/**
* Computes an offset shape (as in "path offsetting") of given shape and offset
* distance `dist`.
*
* @remarks
* The implementation for polygons and convex polygons is _very_ naive and only
* intended for (some basic) convex cases. See
* [thi.ng/geom-sdf](https://thi.ng/thi.ng/geom-sdf) package for more flexible &
* advanced usage.
*
* For complex polygons, the vertex order of holes plays a role here (assumed to
* be the reverse of the boundary's order).
*
* Currently only implemented for:
*
* - {@link AABB}
* - {@link Circle}
* - {@link ComplexPolygon} (convex only)
* - {@link Line}
* - {@link Polygon} (convex only)
* - {@link Rect}
*
* @param shape
* @param dist
*/
export declare const offset: OffsetFn;
//# sourceMappingURL=offset.d.ts.map