import { z } from 'zod'; import { AngularDirection, ClientXY, clientXYZ, Direction, NumberCouple, XY, xyZ } from '../base'; import { direction } from '../direction'; import { location } from '../location'; export { type ClientXY as Client, clientXYZ, type XY, xyZ }; /** A crude representation of a {@link XY} coordinate as a zod schema. */ export declare const crudeZ: z.ZodUnion, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{ width: z.ZodNumber; height: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ signedWidth: z.ZodNumber; signedHeight: z.ZodNumber; }, z.core.$strip>, z.ZodObject<{ clientX: z.ZodNumber; clientY: z.ZodNumber; }, z.core.$strip>]>; /** A crude representation of a {@link XY} coordinate. */ export type Crude = z.infer; /** * @constructs XY * @param x - A crude representation of the XY coordinate as a number, number couple, * dimensions, signed dimensions, or mouse event. If it's a mouse event, the clientX and * clientY coordinates are preferred over the x and y coordinates. * @param y - If x is a number, the y coordinate. If x is a number and this argument is * not given, the y coordinate is assumed to be the same as the x coordinate. */ export declare const construct: (x: Crude | Direction, y?: number) => XY; /** An x and y coordinate of zero */ export declare const ZERO: XY; /** An x and y coordinate of one */ export declare const ONE: XY; /** An x and y coordinate of infinity */ export declare const INFINITY: XY; /** An x and y coordinate of NaN */ export declare const NAN: XY; /** @returns true if the two XY coordinates are semantically equal. */ export declare const equals: (a: Crude, b: Crude, threshold?: number) => boolean; /** Is zero is true if the XY coordinate has a semantic x and y value of zero. */ export declare const isZero: (c: Crude) => boolean; /** * @returns the given coordinate scaled by the given factors. If only one factor is given, * the y factor is assumed to be the same as the x factor. */ export declare const scale: (c: Crude, x: number | Crude, y?: number) => XY; /** @returns the given coordinate translated in the X direction by the given amount. */ export declare const translateX: (c: Crude, x: number) => XY; /** @returns the given coordinate translated in the Y direction by the given amount. */ export declare const translateY: (c: Crude, y: number) => XY; interface Translate { /** @returns the sum of the given coordinates. */ (a: Crude, b: Crude, ...cb: Crude[]): XY; /** @returns the coordinates translated in the given direction by the given value. */ (a: Crude, direction: Direction, value: number): XY; /** @returns the coordinates translated by the given amount. */ (a: Crude, direction: location.XY, xy: Crude): XY; } export declare const translate: Translate; /** * @returns the given coordinate the given direction set to the given value. * @example set({ x: 1, y: 2 }, "x", 3) // { x: 3, y: 2 } */ export declare const set: (c: Crude, direction: direction.Crude, value: number) => XY; /** @returns the magnitude of the distance between the two given coordinates. */ export declare const distance: (ca: Crude, cb: Crude) => number; /** * @returns the translation that would need to be applied to move the first coordinate * to the second coordinate. */ export declare const translation: (to: Crude, from: Crude) => XY; /** @returns true if both the x and y coordinates of the given coordinate are NaN. */ export declare const isNan: (a: Crude) => boolean; /** @returns true if both the x and y coordinates of the given coordinate are finite. */ export declare const isFinite: (a: Crude) => boolean; /** @returns the coordinate represented as a couple of the form [x, y]. */ export declare const couple: (a: Crude) => NumberCouple; /** @returns the coordinate represented as css properties in the form { left, top }. */ export declare const css: (a: Crude) => { left: number; top: number; }; /** * Truncate the given coordinates to the given precision. * @param a - The coordinates to truncate. * @param precision - The number of decimal places to truncate to. * @returns The truncated coordinates. */ export declare const truncate: (a: Crude, precision?: number) => XY; /** * Subtracts the second coordinate from the first coordinate. * @param a - The first coordinate. * @param b - The second coordinate. * @returns The difference between the two coordinates. */ export declare const sub: (a: Crude, b: Crude) => XY; /** * Interprets the given coordinates as a vector and returns the normal of the given * vector. * @param a - The coordinates to get the normal of. * @returns The normal of the given coordinates. */ export declare const normal: (a: Crude) => XY; /** * Interprets the given coordinates as a vector and returns the unit vector of the given * vector. * @param a - The coordinates to get the unit vector of. * @returns The unit vector of the given coordinates. */ export declare const normalize: (a: Crude) => XY; /** * @returns the average of the given coordinates. * @param coordinates - The coordinates to average. */ export declare const average: (...coordinates: Crude[]) => XY; /** * Calculates the miter vectors for the given path and offset. This function is useful * for calculate the translations need to create an offset and parallel path to the * given path. * @param path - The path to calculate the miters for. * @param offset - The magnitude of the miter vectors. * @returns The miter vectors for the given path. */ export declare const calculateMiters: (path: XY[], offset: number) => XY[]; /** * Swaps the x and y coordinates of a point. * @param a - The coordinate to swap. Can be provided in any supported format (couple, object, dimensions, etc.) * @returns A new XY coordinate with the x and y values swapped. * @example * swap([1, 2]) // returns { x: 2, y: 1 } * swap({ x: 3, y: 4 }) // returns { x: 4, y: 3 } * swap({ width: 5, height: 6 }) // returns { x: 6, y: 5 } */ export declare const swap: (a: Crude) => XY; export declare const round: (a: Crude) => XY; /** * Reciprocal of a point. * @param a - The coordinate to invert. Can be provided in any supported format (couple, object, dimensions, etc.) * @returns A new XY coordinate with the x and y values inverted. * @example * reciprocal([1, 2]) // returns { x: 1, y: 0.5 } * reciprocal({ x: 3, y: 4 }) // returns { x: 0.3333333333333333, y: 0.25 } * reciprocal({ width: 5, height: 6 }) // returns { x: 0.2, y: 0.16666666666666666 } */ export declare const reciprocal: (a: Crude) => XY; /** * Rotates a point 90 degrees around a center point. * @param point - The point to rotate. * @param center - The center point to rotate around. * @param dir - The direction to rotate (clockwise or counterclockwise). * @returns The rotated point. */ export declare const rotate: (point: Crude, center: Crude, dir: AngularDirection) => XY; //# sourceMappingURL=xy.d.ts.map