List of utility methods to do Rectangle Contain
boolean | contains(Rectangle c, Rectangle a) contains return c.x <= a.x + a.width && c.x + c.width > a.x && c.y <= a.y + a.height && c.y + c.height > a.y;
|
boolean | contains(Rectangle rect1, Rectangle rect2) Returns true if the first rectangle completely contains the second one.
return (rect2.x >= rect1.x) && (rect2.y >= rect1.y) && (rect2.x + rect2.width <= rect1.x + rect1.width)
&& (rect2.y + rect2.height <= rect1.y + rect1.height);
|
Rectangle | stretchToFit(Rectangle container, Rectangle item) stretch To Fit double scale = scaleProportional(container, item); if (scale < 1) { return item; } else { return new Rectangle((int) (item.width * scale), (int) (item.height * scale)); |