intersection method
Returns the intersection between this rectangle and r
.
Implementation
PRectangle intersection(PRectangle r) {
final src1 = this;
final src2 = r;
final x = math.max(src1.x, src2.x);
final y = math.max(src1.y, src2.y);
final maxx = math.min(src1.maxX, src2.maxX);
final maxy = math.min(src1.maxY, src2.maxY);
return PRectangle(x, y, maxx - x, maxy - y);
}