@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
128 lines • 5.66 kB
TypeScript
import type { MultiFn2O } from "@thi.ng/defmulti";
import type { IShape, IShape2, IShape3, SubdivKernel } from "./api.js";
import type { Arc } from "./api/arc.js";
import type { Circle } from "./api/circle.js";
import { ComplexPolygon } from "./api/complex-polygon.js";
import type { Ellipse } from "./api/ellipse.js";
import { Group } from "./api/group.js";
import { Group3 } from "./api/group3.js";
import type { Line } from "./api/line.js";
import type { Line3 } from "./api/line3.js";
import { Polygon } from "./api/polygon.js";
import { Polygon3 } from "./api/polygon3.js";
import { Polyline } from "./api/polyline.js";
import { Polyline3 } from "./api/polyline3.js";
import type { Quad } from "./api/quad.js";
import type { Quad3 } from "./api/quad3.js";
import type { Rect } from "./api/rect.js";
import type { Triangle } from "./api/triangle.js";
import type { Triangle3 } from "./api/triangle3.js";
/**
* Function overrides for {@link subdivCurve}.
*/
export type SubdivCurveFn = {
(shape: Arc, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polyline;
(shape: Circle, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: Ellipse, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: ComplexPolygon, kernel: SubdivKernel | SubdivKernel[], iter?: number): ComplexPolygon;
(shape: Group, kernel: SubdivKernel | SubdivKernel[], iter?: number): Group;
(shape: Group3, kernel: SubdivKernel | SubdivKernel[], iter?: number): Group3;
(shape: Line, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polyline;
(shape: Line3, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polyline3;
(shape: Polygon, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: Polyline, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polyline;
(shape: Polyline3, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polyline3;
(shape: Quad, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: Quad3, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon3;
(shape: Rect, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: Triangle, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon;
(shape: Triangle3, kernel: SubdivKernel | SubdivKernel[], iter?: number): Polygon3;
(shape: IShape2, kernel: SubdivKernel | SubdivKernel[], iter?: number): IShape2;
(shape: IShape3, kernel: SubdivKernel | SubdivKernel[], iter?: number): IShape3;
} & MultiFn2O<IShape, SubdivKernel | SubdivKernel[], number, IShape>;
/**
* Iteratively applies
* [`SubdivKernel`](https://docs.thi.ng/umbrella/geom-subdiv-curve/interfaces/SubdivKernel.html)
* (or array of kernels) to given shape. See
* [thi.ng/geom-subdiv-curve](https://thi.ng/thi.ng/geom-subdiv-curve) package
* for further details and description of available subdivision presets.
*
* @remarks
* If only given a single subdivision kernel, a number of iterations can be
* specified (by default only a single iteration is applied).
*
* The following subdivision algorithms are provided:
*
* - {@link SUBDIV_CHAIKIN}
* - {@link SUBDIV_CUBIC}
* - {@link SUBDIV_DISPLACE} (2D only, higher order kernel)
* - {@link SUBDIV_DLG}
* - {@link SUBDIV_MID}
* - {@link SUBDIV_THIRDS}
*
* Currently implemented for:
*
* - {@link Arc}
* - {@link Circle}
* - {@link ComplexPolygon}
* - {@link Ellipse}
* - {@link Group} (if it only contains supported shapes)
* - {@link Group3} (if it only contains supported shapes)
* - {@link Line}
* - {@link Line3}
* - {@link Polygon}
* - {@link Polygon3}
* - {@link Polyline}
* - {@link Polyline3}
* - {@link Quad}
* - {@link Quad3}
* - {@link Rect}
* - {@link Triangle}
* - {@link Triangle3}
*
* @example
* ```ts tangle:../export/subdiv-curve.ts
* import { asSvg, rect, subdivCurve, SUBDIV_CHAIKIN } from "@thi.ng/geom";
*
* console.log(
* asSvg(subdivCurve(rect(100), SUBDIV_CHAIKIN))
* );
* // <polygon points="0,25 25,0 75,0 100,25 100,75 75,100 25,100 0,75"/>
* ```
*
* @param shape
* @param kernel
* @param iter
*/
export declare const subdivCurve: SubdivCurveFn;
/**
* Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_MID`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_MID.html)
*/
export declare const SUBDIV_MID: import("@thi.ng/geom-subdiv-curve").SubdivKernel;
/**
* Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_THIRDS`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_THIRDS.html)
*/
export declare const SUBDIV_THIRDS: import("@thi.ng/geom-subdiv-curve").SubdivKernel;
/**
* Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_CHAIKIN`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_CHAIKIN.html)
*/
export declare const SUBDIV_CHAIKIN: import("@thi.ng/geom-subdiv-curve").SubdivKernel;
/**
* Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_CUBIC`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_CUBIC.html)
*/
export declare const SUBDIV_CUBIC: import("@thi.ng/geom-subdiv-curve").SubdivKernel;
/**
* Higher-order subdiv kernel. Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_DISPLACE`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_DISPLACE.html)
*/
export declare const SUBDIV_DISPLACE: (displace: number[][]) => import("@thi.ng/geom-subdiv-curve").SubdivKernel;
/**
* Re-export of thi.ng/geom-subdiv-curve
* [`SUBDIV_DLG`](https://docs.thi.ng/umbrella/geom-subdiv-curve/variables/SUBDIV_DLG.html)
*/
export declare const SUBDIV_DLG: import("@thi.ng/geom-subdiv-curve").SubdivKernel;
//# sourceMappingURL=subdiv-curve.d.ts.map