Asked • 03/18/19

Clipping a Rectangle in JavaScript?

I'm trying to write a function that takes two possibly overlapping rectangles and returns an array of rectangles that cover the area of rectangle A, but exclude area of rectangle B. I'm having a hard time figuring out what this algorithm looks like as the number of possible collisions is huge and difficult to account for. How would you do this in Javascript?

1 Expert Answer

By:

Jacob K. answered • 05/19/19

Tutor
New to Wyzant

Experienced Computer Web and Game Programmer

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.