import { Bounds, Point } from "../core/interfaces"; /** * Represents the affine transformation of the computed css transform property. * * The array `m = [a b c d tx ty]` represents the homogenous affine transform * matrix: * * A = | a c tx | * | b d ty | * | 0 0 1 | * * A = | m[0] m[2] m[4] | * | m[1] m[3] m[5] | * | 0 0 1 | * * https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix */ export declare type ICssTransformMatrix = [number, number, number, number, number, number]; export declare type ITranslateVector = [number, number]; /** * Checks if x is between a and b. * * @param {number} x The value to test if in range * @param {number} a The beginning of the (inclusive) range * @param {number} b The ending of the (inclusive) range * @return {boolean} Whether x is in [a, b] */ export declare function inRange(x: number, a: number, b: number): boolean; /** * Clamps x to the range [min, max]. * * @param {number} x The value to be clamped. * @param {number} min The minimum value. * @param {number} max The maximum value. * @return {number} A clamped value in the range [min, max]. */ export declare function clamp(x: number, min: number, max: number): number; /** * Applies the accessor, if provided, to each element of `array` and returns the maximum value. * If no maximum value can be computed, returns defaultValue. */ export declare function max(array: C[], defaultValue: C): C; export declare function max(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; /** * Applies the accessor, if provided, to each element of `array` and returns the minimum value. * If no minimum value can be computed, returns defaultValue. */ export declare function min(array: C[], defaultValue: C): C; export declare function min(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; /** * Returns true **only** if x is NaN */ export declare function isNaN(n: any): boolean; /** * Returns true if the argument is a number, which is not NaN * Numbers represented as strings do not pass this function */ export declare function isValidNumber(n: any): boolean; /** * Generates an array of consecutive, strictly increasing numbers * in the range [start, stop) separeted by step */ export declare function range(start: number, stop: number, step?: number): number[]; /** * Returns the square of the distance between two points * * @param {Point} p1 * @param {Point} p2 * @return {number} dist(p1, p2)^2 */ export declare function distanceSquared(p1: Point, p2: Point): number; export declare function degreesToRadians(degree: number): number; /** * Returns if the point is within the bounds. Points along * the bounds are considered "within" as well. * @param {Point} p Point in considerations. * @param {Bounds} bounds Bounds within which to check for inclusion. */ export declare function within(p: Point, bounds: Bounds): boolean; /** * Returns whether the first bounds intersects the second bounds. * Pass primitive numbers directly for performance. * * Assumes width and heights are positive. */ export declare function boundsIntersects(aX: number, aY: number, aWidth: number, aHeight: number, bX: number, bY: number, bWidth: number, bHeight: number): boolean; /** * Returns a `ICssTransformMatrix` representing the cumulative transformation of * the element and all its parents. This transform converts from top-level * clientX/clientY coordinates (such as document mouse events) to internal * component offsetX/offsetY coordinates. * * Use `applyTransform` to convert from client coordinates to element * coordinates, accounting for all CSS transforms applied to that element. * * Note that this handles css `transform` but does not handle css * `transform-origin` values other than default ("50% 50%"). */ export declare function getCumulativeTransform(element: Element): ICssTransformMatrix; /** * Straightforward matrix multiplication of homogenized css transform matrices. */ export declare function multiplyMatrix(a: ICssTransformMatrix, b: ICssTransformMatrix): ICssTransformMatrix; /** * Prepends translation to transformation matrix. * * Equivalent to `multiplyMatrix([1, 0, 0, 1, ...v], b)` */ export declare function premultiplyTranslate(v: ITranslateVector, b: ICssTransformMatrix): ICssTransformMatrix; /** * Appends translation to transformation matrix. * * Equivalent to `multiplyMatrix(a, [1, 0, 0, 1, ...v])` */ export declare function multiplyTranslate(a: ICssTransformMatrix, v: ITranslateVector): ICssTransformMatrix; /** * Analytical inverse of a `ICssTransformMatrix` analogous to a non-singular * homogenous 3x3 matrix. * * http://mathworld.wolfram.com/MatrixInverse.html * https://stackoverflow.com/questions/2624422/efficient-4x4-matrix-inverse-affine-transform */ export declare function invertMatrix(a: ICssTransformMatrix): ICssTransformMatrix; /** * Applies the `ICssTransformMatrix` to the `Point`. * * Returns a new `Point`. */ export declare function applyTransform(a: ICssTransformMatrix, p: Point): Point;