type Point = { x: number; y: number };
type Rect = { x1: number; y1: number; x2: number; y2: number };
const x1 = 0.0, y1 = 0.0;
const x2 = 7.0, y2 = 7.0;
const x = 3.0, y = 2.0;
const pointInRect = (rect: Rect, point: Point): boolean => {
return point.x >= rect.x1 && point.x <= rect.x2 &&
point.y >= rect.y1 && point.y <= rect.y2;
};
const rect: Rect = { x1, y1, x2, y2 };
const point: Point = { x, y };
if (pointInRect(rect, point)) {
console.log("The point is inside the rectangle.");
} else {
console.log("The point is outside the rectangle.");
}
/*
run:
"The point is inside the rectangle."
*/