rectsIntersect = (r1, r2) =>
  r2.x < r1.x + r1.width &&
  r2.x + r2.width > r1.x &&
  r2.y < r1.y + r1.height &&
  r2.y + r2.height > r1.y
Checks if two rectangles intersect.
Both r1 and r2 are expected to have {x, y, width, height}.
@function rectsIntersect
@param {{x:number,y:number,width:number,height:number}} r1 - First rectangle
@param {{x:number,y:number,width:number,height:number}} r2 - Second rectangle
@returns {boolean} True if the rectangles intersect