collidePointRect
Test if a point collides with a rectangle.
Usage
js
import { collidePointRect } from '@studiometa/js-toolkit/utils';
const point = {
x: 0,
y: 0,
};
const rect = {
x: 0,
y: 0,
width: 20,
height: 20,
};
collidePointRect(point, rect); // trueParameters
point({ x: number, y: number }): the point's positionrect({ x: number, y: number, width: number, height: number }): the rectangle's dimensions and position
Return value
boolean: wether the point and rectangle are colliding or not