MCPcopy Create free account
hub / github.com/benfry/processing4 / intersect

Method intersect

core/src/processing/core/PImage.java:1724–1754  ·  view source on GitHub ↗

Check to see if two rectangles intersect one another

(int sx1, int sy1, int sx2, int sy2,
                            int dx1, int dy1, int dx2, int dy2)

Source from the content-addressed store, hash-verified

1722 * Check to see if two rectangles intersect one another
1723 */
1724 private boolean intersect(int sx1, int sy1, int sx2, int sy2,
1725 int dx1, int dy1, int dx2, int dy2) {
1726 int sw = sx2 - sx1 + 1;
1727 int sh = sy2 - sy1 + 1;
1728 int dw = dx2 - dx1 + 1;
1729 int dh = dy2 - dy1 + 1;
1730
1731 if (dx1 < sx1) {
1732 dw += dx1 - sx1;
1733 if (dw > sw) {
1734 dw = sw;
1735 }
1736 } else {
1737 int w = sw + sx1 - dx1;
1738 if (dw > w) {
1739 dw = w;
1740 }
1741 }
1742 if (dy1 < sy1) {
1743 dh += dy1 - sy1;
1744 if (dh > sh) {
1745 dh = sh;
1746 }
1747 } else {
1748 int h = sh + sy1 - dy1;
1749 if (dh > h) {
1750 dh = h;
1751 }
1752 }
1753 return !(dw <= 0 || dh <= 0);
1754 }
1755
1756
1757 //////////////////////////////////////////////////////////////

Callers 1

blendMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected