@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
70 lines • 2.2 kB
TypeScript
import type { MultiFn2 } from "@thi.ng/defmulti";
import type { IShape, IShape2, IShape3, TransformVertexFn } from "./api.js";
import type { Arc } from "./api/arc.js";
import type { Circle } from "./api/circle.js";
import type { Ellipse } from "./api/ellipse.js";
import { Polygon } from "./api/polygon.js";
import { Polyline } from "./api/polyline.js";
import type { Rect } from "./api/rect.js";
/**
* Function overrides for {@link transformVertices}.
*/
export type TransformVerticesFn = {
(shape: Arc, fn: TransformVertexFn): Polyline;
(shape: Circle, fn: TransformVertexFn): Polygon;
(shape: Ellipse, fn: TransformVertexFn): Polygon;
(shape: Rect, fn: TransformVertexFn): Polygon;
<T extends IShape2>(shape: T, fn: TransformVertexFn): T;
<T extends IShape3>(shape: T, fn: TransformVertexFn): T;
} & MultiFn2<IShape, TransformVertexFn, IShape>;
/**
* Similar to {@link transform}. Transforms vertices of given shape with
* provided function, which is being called for each vertex individually and
* should produce a transformation matrix.
*
* @remarks
* Some shape types will be automatically converted to other types prior to
* transformation because they cannot be reliably represented in their original
* type anymore, this includes:
*
* - {@link Arc} => {@link Path} (cubics)
* - {@link Circle} => {@link Path} (cubics)
* - {@link Ellipse} => {@link Path} (cubics)
* - {@link Rect} => {@link Polygon}
*
* Currently implemented for:
*
* - {@link Arc}
* - {@link BPatch}
* - {@link Circle}
* - {@link ComplexPolygon}
* - {@link Cubic}
* - {@link Cubic3}
* - {@link Ellipse}
* - {@link Extra}
* - {@link Group}
* - {@link Group3}
* - {@link Line}
* - {@link Line3}
* - {@link Path}
* - {@link Path3}
* - {@link Points}
* - {@link Points3}
* - {@link Polygon}
* - {@link Polygon3}
* - {@link Polyline}
* - {@link Polyline3}
* - {@link Quad}
* - {@link Quad3}
* - {@link Quadratic}
* - {@link Quadratic3}
* - {@link Rect}
* - {@link Text}
* - {@link Triangle}
* - {@link Triangle3}
*
* @param shape
* @param fn
*/
export declare const transformVertices: TransformVerticesFn;
//# sourceMappingURL=transform-vertices.d.ts.map