9 lines
319 B
TypeScript
9 lines
319 B
TypeScript
export type Point = [x: number, y: number];
|
|
export type Rect = [x: number, y: number, width: number, height: number];
|
|
|
|
export function rectContains(rect: Rect, point: Point): boolean {
|
|
const [x, y, width, height] = rect;
|
|
const [px, py] = point;
|
|
return px >= x && px <= x + width && py >= y && py <= y + height;
|
|
}
|