Offsetting Rectangle Positions to prevent overlap

431 Views Asked by At

I have the following cases where rectangles overlap. enter image description here

I have the coordinates for the intersection rectangle(Blue). How can i offset the starting coordinates(top-left X-Y) of the 2 rectangles to prevent overlapping,provided that i have the coordinates of the intersection rectangle.