UNPKG

svg-path-d

Version:

SVG path data (path[d] attribute content) manipulation library.

68 lines (67 loc) 2.66 kB
/** * A 2D 3x2 matrix with six parameters a, b, c, d, e and f. * It is equivalent to applying the 3x3 transformation matrix: * <pre> * | x1 | | a c e | | x | * | y1 | = | b d f | * | y | * | 1 | | 0 0 1 | | 1 | * </pre> * http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix */ export interface Matrix { a: number; b: number; c: number; d: number; e: number; f: number; } export declare type ReadonlyMatrix = Readonly<Matrix>; export declare function isIdentity(m: ReadonlyMatrix): boolean; export declare function isTranslate(m: ReadonlyMatrix): boolean; export declare function isScale(m: ReadonlyMatrix): boolean; export declare function createIdentity(): Matrix; export declare function createTranslate(x: number, y: number): Matrix; /** * Creates a scale matrix. * @param scaleX The amount by which to scale along the x-axis. * @param scaleY The amount by which to scale along the y-axis. */ export declare function createScale(scaleX: number, scaleY: number): Matrix; /** * Creates a scale about the specified point matrix. * @param scaleX The amount by which to scale along the x-axis. * @param scaleY The amount by which to scale along the y-axis. * @param centerX The x-coordinate of the scale operation's center point. * @param centerY The y-coordinate of the scale operation's center point. */ export declare function createScaleAt(scaleX: number, scaleY: number, centerX: number, centerY: number): Matrix; export declare function createSkew(skewX: number, skewY: number): Matrix; /** * Creates a rotation matrix. * @param angle The rotation angle, in radians. */ export declare function createRotate(angle: number): Matrix; /** * Creates a rotation matrix about the specified point. * @param angle The angle, in radians, by which to rotate. * @param centerX The x-coordinate of the point about which to rotate. * @param centerY The y-coordinate of the point about which to rotate. */ export declare function createRotateAt(angle: number, centerX: number, centerY: number): Matrix; export declare function multiply(A: ReadonlyMatrix, B: ReadonlyMatrix): Matrix; /** * Returns an inverted version of the matrix. * @param m the given matrix */ export declare function invert(m: ReadonlyMatrix): Matrix; export declare function toArray(m: ReadonlyMatrix): number[]; export declare function toString(m: ReadonlyMatrix): string; export declare function decompose(m: ReadonlyMatrix): { translateX: number; translateY: number; rotate: number; scaleX: number; scaleY: number; skew: number; };