+Rect & Rect::operator+=(Point p)
+{
+ if (p.x < l)
+ l = p.x;
+
+ if (p.x > r)
+ r = p.x;
+
+ if (p.y < b)
+ b = p.y;
+
+ if (p.y > t)
+ t = p.y;
+
+ return *this;
+}
+
+//
+// We use this to give a rect an array-like access, which allows access of the
+// rect in TLBR order (from 0 to 3). Also, values greater than 3 are treated
+// as mod 4.
+//
+double & Rect::operator[](int idx)
+{
+ idx = idx % 4;
+
+ switch (idx)
+ {
+ case 0:
+ return t;
+ case 1:
+ return l;
+ case 2:
+ return b;
+ }
+
+ return r;
+}
+