@thi.ng/geom
Version:
Functional, polymorphic API for 2D geometry types & SVG generation
71 lines • 2.08 kB
TypeScript
import type { MultiFn2 } from "@thi.ng/defmulti";
import type { ReadonlyMat } from "@thi.ng/matrices";
import type { IShape, IShape2, IShape3 } 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 { Path } from "./api/path.js";
import { Quad } from "./api/quad.js";
import type { Rect } from "./api/rect.js";
/**
* Function overrides for {@link transform}.
*/
export type TransformFn = {
(shape: Arc, mat: ReadonlyMat): Path;
(shape: Circle, mat: ReadonlyMat): Path;
(shape: Ellipse, mat: ReadonlyMat): Path;
(shape: Rect, mat: ReadonlyMat): Quad;
<T extends IShape2>(shape: T, mat: ReadonlyMat): T;
<T extends IShape3>(shape: T, mat: ReadonlyMat): T;
} & MultiFn2<IShape, ReadonlyMat, IShape>;
/**
* Transforms given shape with provided matrix.
*
* @remarks
* A 2x3 transform matrix is assumed for 2D shapes and 4x4 matrix for 3D shapes.
* 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 Quad}
*
* 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 Ray}
* - {@link Rect}
* - {@link Text}
* - {@link Triangle}
* - {@link Triangle3}
*
* @param shape
* @param mat
*/
export declare const transform: TransformFn;
//# sourceMappingURL=transform.d.ts.map