16 lines
273 B
TypeScript
16 lines
273 B
TypeScript
|
|
export type Rect = {
|
||
|
|
top: number;
|
||
|
|
left: number;
|
||
|
|
right: number;
|
||
|
|
bottom: number;
|
||
|
|
};
|
||
|
|
|
||
|
|
export const areIntersecting = (r1: Rect, r2: Rect) => {
|
||
|
|
return !(
|
||
|
|
r2.left >= r1.right ||
|
||
|
|
r2.right <= r1.left ||
|
||
|
|
r2.top >= r1.bottom ||
|
||
|
|
r2.bottom <= r1.top
|
||
|
|
);
|
||
|
|
};
|