(Rectangle r)
| 103 | } |
| 104 | |
| 105 | public boolean intersects(Rectangle r) { |
| 106 | int tw = this.width; |
| 107 | int th = this.height; |
| 108 | int rw = r.getWidth(); |
| 109 | int rh = r.getHeight(); |
| 110 | if (rw > 0 && rh > 0 && tw > 0 && th > 0) { |
| 111 | int tx = this.x; |
| 112 | int ty = this.y; |
| 113 | int rx = r.getX(); |
| 114 | int ry = r.getY(); |
| 115 | rw += rx; |
| 116 | rh += ry; |
| 117 | tw += tx; |
| 118 | th += ty; |
| 119 | return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry); |
| 120 | } else { |
| 121 | return false; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | public Rectangle intersection(Rectangle r, Rectangle dest) { |
| 126 | int tx1 = this.x; |