import { z } from 'zod'; import { bounds } from '../bounds'; import { dimensions } from '../dimensions'; import { direction } from '../direction'; import { location } from '../location'; import { xy } from '../xy'; export declare const cssBox: z.ZodObject<{ top: z.ZodUnion; left: z.ZodUnion; width: z.ZodUnion; height: z.ZodUnion; }, z.core.$strip>; export declare const domRect: z.ZodObject<{ left: z.ZodNumber; top: z.ZodNumber; right: z.ZodNumber; bottom: z.ZodNumber; }, z.core.$strip>; export declare const box: z.ZodObject<{ one: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strip>; two: z.ZodObject<{ x: z.ZodNumber; y: z.ZodNumber; }, z.core.$strip>; root: z.ZodObject<{ x: z.ZodEnum<{ left: "left"; right: "right"; }>; y: z.ZodEnum<{ top: "top"; bottom: "bottom"; }>; }, z.core.$strip>; }, z.core.$strip>; export type Box = z.infer; export type CSS = z.infer; export type DOMRect = z.infer; export type Crude = DOMRect | Box | { getBoundingClientRect: () => DOMRect; }; /** A box centered at (0,0) with a width and height of 0. */ export declare const ZERO: { one: xy.XY; two: xy.XY; root: import('../types.gen').CornerLocation; }; /** * A box centered at (0,0) with a width and height of 1, and rooted in the * bottom left. Note that pixel space is typically rooted in the top left. */ export declare const DECIMAL: { one: xy.XY; two: xy.XY; root: import('../types.gen').CornerLocation; }; export declare const copy: (b: Box, root?: location.Corner) => Box; /** * Box represents a general box in 2D space. It typically represents a bounding box * for a DOM element, but can also represent a box in clip space or decimal space. * * It's important to note that the behavior of a Box varies depending on its coordinate * system.Make sure you're aware of which coordinate system you're using. * * Many of the properties and methods on a Box access the same semantic value. The * different accessors are there for ease of use and semantics. */ export declare const construct: (first: number | DOMRect | xy.XY | Box | { getBoundingClientRect: () => DOMRect; }, second?: number | xy.XY | dimensions.Dimensions | dimensions.Signed, width?: number, height?: number, coordinateRoot?: location.Corner) => Box; export interface Resize { /** * Sets the dimensions of the box to the given dimensions. * @example resize(b, { width: 10, height: 10 }) // Sets the box to a 10x10 box. */ (b: Crude, dims: dimensions.Dimensions | dimensions.Signed): Box; /** * Sets the dimension along the given direction to the given amount. * @example resize(b, "x", 10) // Sets the width of the box to 10. * @example resize(b, "y", 10) // Sets the height of the box to 10. */ (b: Crude, direction: direction.Direction, amount: number): Box; } export declare const resize: Resize; /** * Checks if a box contains a point or another box. * * @param container - The container box to check against. * @param value - The point or box to check if it is contained in the container. * @param inclusive - Whether the edges of the box are inclusive or exclusive. * @returns true if the box inclusively contains the point or box and false otherwise. */ export declare const contains: (container: Crude, value: Box | xy.XY, inclusive?: boolean) => boolean; /** * @returns true if the given box is semantically equal to this box and false otherwise. */ export declare const equals: (a: Box, b: Box) => boolean; /** * @returns the dimensions of the box. Note that these dimensions are guaranteed to * be positive. To get the signed dimensions, use the `signedDims` property. */ export declare const dims: (b: Box) => dimensions.Dimensions; /** * @returns the dimensions of the box. Note that these dimensions may be negative. * To get the unsigned dimensions, use the `dims` property. */ export declare const signedDims: (b: Box) => dimensions.Signed; /** * @returns the css representation of the box. */ export declare const css: (b: Box) => CSS; export declare const dim: (b: Crude, dir: direction.Crude, signed?: boolean) => number; /** @returns the pont corresponding to the given corner of the box. */ export declare const xyLoc: (b: Crude, l: location.XY) => xy.XY; /** * @returns a one dimensional coordinate corresponding to the location of the given * side of the box i.e. the x coordinate of the left side, the y coordinate of the * top side, etc. */ export declare const loc: (b: Crude, loc: location.Location) => number; /** @returns true if the area of the box is 0 and false otherwise. */ export declare const areaIsZero: (b: Box) => boolean; /** @returns the width of the box. */ export declare const width: (b: Crude) => number; /** @returns the height of the box. */ export declare const height: (b: Crude) => number; /** * @returns the signed width of the box, which will be negative if the x value of the * first coordinate is less than the x value of the second coordinate. */ export declare const signedWidth: (b: Crude) => number; /** * @returns the signed height of the box, which will be negative if the y value of the * first coordinate is less than the y value of the second coordinate. */ export declare const signedHeight: (b: Crude) => number; export declare const topLeft: (b: Crude) => xy.XY; export declare const topCenter: (b: Crude) => xy.XY; export declare const topRight: (b: Crude) => xy.XY; export declare const bottomLeft: (b: Crude) => xy.XY; export declare const bottomCenter: (b: Crude) => xy.XY; export declare const bottomRight: (b: Crude) => xy.XY; export declare const centerLeft: (b: Crude) => xy.XY; export declare const centerRight: (b: Crude) => xy.XY; export declare const right: (b: Crude) => number; export declare const bottom: (b: Crude) => number; export declare const left: (b: Crude) => number; export declare const top: (b: Crude) => number; export declare const center: (b: Crude) => xy.XY; export declare const x: (b: Crude) => number; export declare const y: (b: Crude) => number; export declare const root: (b: Crude) => xy.XY; /** * @returns the bounds of the box along the x axis i.e. if the box root is top left, * the lower bound is the x coordinate of the left side of the box and the upper bound * is the x coordinate of the right side of the box. * @param b - The box to get the bounds of. */ export declare const xBounds: (b: Crude) => bounds.Bounds; /** * @returns the bounds of the box along the y axis i.e. if the box root is top left, * the lower bound is the y coordinate of the top side of the box and the upper bound * is the y coordinate of the bottom side of the box. * @param b - The box to get the bounds of. */ export declare const yBounds: (b: Crude) => bounds.Bounds; export declare const reRoot: (b: Box, corner: location.Corner) => Box; export declare const edgePoints: (b: Crude, loc: location.Location) => [xy.XY, xy.XY]; /** * Reposition a box so that it is centered within a given bound. * * @param target The box to reposition - Only works if the root is topLeft * @param bound The box to reposition within - Only works if the root is topLeft * @returns the repositioned box */ export declare const positionInCenter: (target_: Crude, bound_: Crude) => Box; /** */ export declare const isBox: (value: unknown) => value is Box; export declare const aspect: (b: Box) => number; interface Translate { /** @returns the box translated by the given coordinates. */ (b: Crude, t: xy.Crude): Box; /** @returns the box translated in the given direction by the given amount. */ (b: Crude, direction: direction.Direction, amount: number): Box; } export declare const translate: Translate; /** @returns a box representing the intersection of the two given boxes. */ export declare const intersection: (a: Box, b: Box) => Box; /** @returns the area of the box. */ export declare const area: (b: Box) => number; /** * Truncates the coordinates of the box to the given precision. * @param b - The box to truncate. * @param precision - The number of decimal places to truncate to. * @returns the truncated box. */ export declare const truncate: (b: Crude, precision: number) => Box; /** * Constructs a box from a particular corner, and then reinterprets the box in order * to define it from a different corner. * * @example * const b = box.construct(0, 0, 10, 10, location.BOTTOM_LEFT, location.TOP_LEFT); * // b is now a box rooted in the top left corner with it's first coordinate at * // (0, 10) and it's second coordinate at (10, 0). * * @param x - The x coordinate of the first point. * @param y - The y coordinate of the first point. * @param width - The width of the box. * @param height - The height of the box. * @param currRoot - The current root of the box i.e. the corner that x and y represent. * @param newRoot - The new root of the box i.e. the corner that the box should be * reinterpreted from. * @returns the box reinterpreted from the new root. */ export declare const constructWithAlternateRoot: (x: number, y: number, width: number, height: number, currRoot: location.XY, newRoot: location.Corner) => Box; export declare const round: (b: Crude) => Box; export {}; //# sourceMappingURL=box.d.ts.map