@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
63 lines • 1.71 kB
TypeScript
import type { MultiFn1O } from "@thi.ng/defmulti";
import type { Vec } from "@thi.ng/vectors";
import type { IShape, SamplingOpts } from "./api.js";
/**
* Extracts/samples vertices from given shape's boundary and returns them as
* array. Some shapes also support
* [`SamplingOpts`](https://docs.thi.ng/umbrella/geom-resample/interfaces/SamplingOpts.html).
*
* @remarks
* The given sampling options (if any) can also be overridden per shape using
* the special `__samples` attribute. If specified, these will be merged with
* the options.
*
* Currently implemented for:
*
* - {@link AABB}
* - {@link Arc}
* - {@link BPatch}
* - {@link Circle}
* - {@link ComplexPolygon}
* - {@link Cubic}
* - {@link Ellipse}
* - {@link Extra}
* - {@link Group}
* - {@link Line}
* - {@link Path}
* - {@link Points}
* - {@link Points3}
* - {@link Quad}
* - {@link Quadratic}
* - {@link Rect}
* - {@link Triangle}
*
* @example
* ```ts
* import { circle, vertices } from "@thi.ng/geom";
*
* // using default
* vertices(circle(100))
*
* // specify resolution only
* vertices(circle(100), 6)
*
* // specify more advanced options
* vertices(circle(100), { dist: 10 })
*
* // using shape attribs
* vertices(circle(100, { __samples: { dist: 10 } }))
* ```
*
* @param shape
* @param opts
*/
export declare const vertices: MultiFn1O<IShape, number | Partial<SamplingOpts>, Vec[]>;
/**
* Takes an array of vertices or an `IShape`. If the latter, calls
* {@link vertices} with default options and returns result, else returns
* original array.
*
* @param shape -
*/
export declare const ensureVertices: (shape: IShape | Vec[]) => Vec<number>[];
//# sourceMappingURL=vertices.d.ts.map