DEV Community

Cover image for Rectangle Intersection
Zevan Rosser
Zevan Rosser

Posted on

Rectangle Intersection

Very useful for complex UI or simple games... checking if two arbitrary non-rotated rectangles intersect:

This is the real key, most of the rest of the code here is boilerplate...

 rectA.left < rectB.right &&
 rectA.right > rectB.left &&
 rectA.top < rectB.bottom &&
 rectA.bottom > rectB.top
Enter fullscreen mode Exit fullscreen mode

See more stuff like this over @ Snippet Zone

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series