2 // rect.cpp: Rectangle object implementation
4 // Part of the Architektonas Project
5 // (C) 2016 Underground Software
6 // See the README and GPLv3 files for licensing and warranty information
8 // JLH = James Hammons <jlhamm@acm.org>
11 // --- ---------- ------------------------------------------------------------
12 // JLH 11/10/2016 Created this file
19 Rect::Rect(): l(0), r(0), t(0), b(0)
23 Rect::Rect(double tt, double ll, double bb, double rr):
24 l(ll), r(rr), t(tt), b(bb)
29 Rect::Rect(Point tl, Point br): l(tl.x), r(br.x), t(tl.y), b(br.y)
34 Rect::Rect(Point p): l(p.x), r(p.x), t(p.y), b(p.y)
38 Rect & Rect::operator*=(double scale)
48 Rect & Rect::operator|=(Rect r2)
50 //printf("operatore|=\nthis = (%lf, %lf, %lf, %lf), r = (%lf, %lf, %lf, %lf)\n", l, t, r, b, r2.l, r2.t, r2.r, r2.b);
66 Rect & Rect::operator+=(Point p)
84 // We use this to give a rect an array-like access, which allows access of the
85 // rect in TLBR order (from 0 to 3). Also, values greater than 3 are treated
88 double & Rect::operator[](int idx)
105 void Rect::Normalize(void)
122 void Rect::Translate(Point p)
130 void Rect::Expand(double amt)
138 double Rect::Width(void)
143 double Rect::Height(void)
148 bool Rect::Contains(Point p)
150 return ((p.x >= l) && (p.x <= r) && (p.y >= b) && (p.y <= t) ? true : false);
153 bool Rect::Contains(Rect rect)
155 return ((rect.l >= l) && (rect.r <= r) && (rect.b >= b) && (rect.t <= t) ? true : false);
158 Point Rect::TopLeft(void)
163 Point Rect::TopRight(void)
168 Point Rect::BottomLeft(void)
173 Point Rect::BottomRight(void)