UNPKG

@mescius/dspdfviewer

Version:
97 lines (96 loc) 3.52 kB
/** * Decimal round down **/ export declare function floor10(value: any, exp: any): any; /** * Decimal round up **/ export declare function ceil10(value: any, exp: any): any; /** * Decimal round to nearest * @example * ```javascript * round10(55.55, -1); // result: 55.6 * round10(55.549, -1); // result: 55.5 * round10(55, 1); // result: 60 * round10(1.005, -2); // result: 1.01 -- compare this result with Math.round(1.005*100)/100 * // (Note rounding mistake due to inaccurate floating point arithmetic) * ``` * @param value * @param exp */ export declare function round10(value: number, exp?: number): number; /** * Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2) * For coordinate systems whose origin lies in the bottom-left, this * means normalization to (BL,TR) ordering. For systems with origin in the * top-left, this means (TL,BR) ordering. * @param rect **/ export declare function normalizeRect(rect: number[]): number[]; /** * Rotate point (x,y) coordinates around point (cx, cy). * Note, this function assumes a Cartesian coordinate system - values on the Y axis become higher as you go up. * @param cx center point x * @param cy center point y * @param x point to rotate, x * @param y point to rotate, y * @param angle rotation angle * @param isDeg specifies if rotation angle is in degrees. **/ export declare function rotatePoint(cx: number, cy: number, x: number, y: number, angle: number, isDeg?: boolean): number[]; /** * Calculates the counter clockwise angle between two vectors. * @returns Returns angle in degrees. * @param p1 First vector point, [x1, y1]. * @param p2 Second vector point, [x2, y2]. * @param c A common center point that exists on both vectors, [cx, cy]. */ export declare function findVectorsAngle(p1: number[], p2: number[], cp: number[]): number; /** * Convert radians to degrees. * @param radians **/ export declare function rad2Deg(radians: number): number; /** * Convert degrees to radians. * @param radians **/ export declare function deg2rad(degrees: number): number; /** * Rotate the rectangle. * @param rect rectangle coordinates [x1, y1, x2, y2]. * @param cxcy center point [x, y]. * @param angle rotation angle (default - in degrees) * @param isDeg specifies if rotation angle is in degrees. Default is true. */ export declare function rotateRect(rect: number[], cxcy: number[] | null, angle: number, isDeg?: boolean): number[]; export declare function reverseRotateRect(transformedRect: number[], cxcy: number[] | null, angleDeg: any): number[]; export declare function getDistance(x1: any, y1: any, x2: any, y2: any): number; /** * Gets angle (radians) at point x2,y2. * @param x1 * @param y1 * @param x2 * @param y2 */ export declare function getAngle(x1: any, y1: any, x2: any, y2: any): number; /** * @ignore exclude from docs * @param rect * @param cxcy * @param angle * @param isDeg */ export declare function rotateRectAndFillBoth(rect: number[], cxcy: number[], angle: number, isDeg?: boolean): { rotatedRect: number[]; transformedRect: number[]; }; /** * Finds intersection point between two lines AB and CD. * @param A point A: [x, y] * @param B point B: [x, y] * @param C point C: [x, y] * @param D point D: [x, y] */ export declare function findLinesIntersection(A: number[], B: number[], C: number[], D: number[]): number[] | null;