import { CompassCorners, Point, ReadOnlyPoint, ReadOnlyRect, ReadOnlySize, ReadOnlyTypedArray, Size } from '../interfaces'; /** * A rectangle, represented as a float64 array of 4 numbers: [x, y, width, height]. * * This class is a subclass of Float64Array, and so has all the methods of that class. Notably, * {@link Rectangle.from} can be used to convert a {@link ReadOnlyRect}. Typing of this however, * is broken due to the base TS lib returning Float64Array rather than `this`. * * Sub-array properties ({@link Float64Array.subarray}): * - {@link pos}: The position of the top-left corner of the rectangle. * - {@link size}: The size of the rectangle. */ export declare class Rectangle extends Float64Array { #private; constructor(x?: number, y?: number, width?: number, height?: number); static from([x, y, width, height]: ReadOnlyRect): Rectangle; /** * Creates a new rectangle positioned at the given centre, with the given width/height. * @param centre The centre of the rectangle, as an `[x, y]` point * @param width The width of the rectangle * @param height The height of the rectangle. Default: {@link width} * @returns A new rectangle whose centre is at {@link x} */ static fromCentre([x, y]: ReadOnlyPoint, width: number, height?: number): Rectangle; static ensureRect(rect: ReadOnlyRect): Rectangle; subarray(begin?: number, end?: number): Float64Array; /** * A reference to the position of the top-left corner of this rectangle. * * Updating the values of the returned object will update this rectangle. */ get pos(): Point; set pos(value: ReadOnlyPoint); /** * A reference to the size of this rectangle. * * Updating the values of the returned object will update this rectangle. */ get size(): Size; set size(value: ReadOnlySize); /** The x co-ordinate of the top-left corner of this rectangle. */ get x(): number; set x(value: number); /** The y co-ordinate of the top-left corner of this rectangle. */ get y(): number; set y(value: number); /** The width of this rectangle. */ get width(): number; set width(value: number); /** The height of this rectangle. */ get height(): number; set height(value: number); /** The x co-ordinate of the left edge of this rectangle. */ get left(): number; set left(value: number); /** The y co-ordinate of the top edge of this rectangle. */ get top(): number; set top(value: number); /** The x co-ordinate of the right edge of this rectangle. */ get right(): number; set right(value: number); /** The y co-ordinate of the bottom edge of this rectangle. */ get bottom(): number; set bottom(value: number); /** The x co-ordinate of the centre of this rectangle. */ get centreX(): number; /** The y co-ordinate of the centre of this rectangle. */ get centreY(): number; /** * Updates the rectangle to the values of {@link rect}. * @param rect The rectangle to update to. */ updateTo(rect: ReadOnlyRect): void; /** * Checks if the point [{@link x}, {@link y}] is inside this rectangle. * @param x The x-coordinate to check * @param y The y-coordinate to check * @returns `true` if the point is inside this rectangle, otherwise `false`. */ containsXy(x: number, y: number): boolean; /** * Checks if {@link point} is inside this rectangle. * @param point The point to check * @returns `true` if {@link point} is inside this rectangle, otherwise `false`. */ containsPoint([x, y]: ReadOnlyPoint): boolean; /** * Checks if {@link other} is a smaller rectangle inside this rectangle. * One **must** be larger than the other; identical rectangles are not considered to contain each other. * @param other The rectangle to check * @returns `true` if {@link other} is inside this rectangle, otherwise `false`. */ containsRect(other: ReadOnlyRect): boolean; /** * Checks if {@link rect} overlaps with this rectangle. * @param rect The rectangle to check * @returns `true` if {@link rect} overlaps with this rectangle, otherwise `false`. */ overlaps(rect: ReadOnlyRect): boolean; /** * Finds the corner (if any) of this rectangle that contains the point [{@link x}, {@link y}]. * @param x The x-coordinate to check * @param y The y-coordinate to check * @param cornerSize Each corner is treated as an inset square with this width and height. * @returns The compass direction of the corner that contains the point, or `undefined` if the point is not in any corner. */ findContainingCorner(x: number, y: number, cornerSize: number): CompassCorners | undefined; /** @returns `true` if the point [{@link x}, {@link y}] is in the top-left corner of this rectangle, otherwise `false`. */ isInTopLeftCorner(x: number, y: number, cornerSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the top-right corner of this rectangle, otherwise `false`. */ isInTopRightCorner(x: number, y: number, cornerSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-left corner of this rectangle, otherwise `false`. */ isInBottomLeftCorner(x: number, y: number, cornerSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom-right corner of this rectangle, otherwise `false`. */ isInBottomRightCorner(x: number, y: number, cornerSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the top edge of this rectangle, otherwise `false`. */ isInTopEdge(x: number, y: number, edgeSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the bottom edge of this rectangle, otherwise `false`. */ isInBottomEdge(x: number, y: number, edgeSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the left edge of this rectangle, otherwise `false`. */ isInLeftEdge(x: number, y: number, edgeSize: number): boolean; /** @returns `true` if the point [{@link x}, {@link y}] is in the right edge of this rectangle, otherwise `false`. */ isInRightEdge(x: number, y: number, edgeSize: number): boolean; /** @returns The centre point of this rectangle, as a new {@link Point}. */ getCentre(): Point; /** @returns The area of this rectangle. */ getArea(): number; /** @returns The perimeter of this rectangle. */ getPerimeter(): number; /** @returns The top-left corner of this rectangle, as a new {@link Point}. */ getTopLeft(): Point; /** @returns The bottom-right corner of this rectangle, as a new {@link Point}. */ getBottomRight(): Point; /** @returns The width and height of this rectangle, as a new {@link Size}. */ getSize(): Size; /** @returns The offset from the top-left of this rectangle to the point [{@link x}, {@link y}], as a new {@link Point}. */ getOffsetTo([x, y]: ReadOnlyPoint): Point; /** @returns The offset from the point [{@link x}, {@link y}] to the top-left of this rectangle, as a new {@link Point}. */ getOffsetFrom([x, y]: ReadOnlyPoint): Point; /** Resizes the rectangle without moving it, setting its top-left corner to [{@link x}, {@link y}]. */ resizeTopLeft(x1: number, y1: number): void; /** Resizes the rectangle without moving it, setting its bottom-left corner to [{@link x}, {@link y}]. */ resizeBottomLeft(x1: number, y2: number): void; /** Resizes the rectangle without moving it, setting its top-right corner to [{@link x}, {@link y}]. */ resizeTopRight(x2: number, y1: number): void; /** Resizes the rectangle without moving it, setting its bottom-right corner to [{@link x}, {@link y}]. */ resizeBottomRight(x2: number, y2: number): void; /** Sets the width without moving the right edge (changes position) */ setWidthRightAnchored(width: number): void; /** Sets the height without moving the bottom edge (changes position) */ setHeightBottomAnchored(height: number): void; clone(): Rectangle; /** Alias of {@link export}. */ toArray(): [number, number, number, number]; /** @returns A new, untyped array (serializable) containing the values of this rectangle. */ export(): [number, number, number, number]; /** * Draws a debug outline of this rectangle. * @internal Convenience debug/development interface; not for production use. */ _drawDebug(ctx: CanvasRenderingContext2D, colour?: string): void; } export type ReadOnlyRectangle = Omit, "setHeightBottomAnchored" | "setWidthRightAnchored" | "resizeTopLeft" | "resizeBottomLeft" | "resizeTopRight" | "resizeBottomRight" | "resizeBottomRight" | "updateTo">;