X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Frect.cpp;fp=src%2Frect.cpp;h=54f44ddf73abcb404c95d1b6d397674a90a16b8c;hb=1d17841ed1d003060250dc2ef8dd6785fa02a07f;hp=693cf31582e34b3533bb1df7bbd73a9a60b71fa6;hpb=eb39f1bb5e6518c5dc4f4dbd3c88912a97192e95;p=architektonas diff --git a/src/rect.cpp b/src/rect.cpp index 693cf31..54f44dd 100644 --- a/src/rect.cpp +++ b/src/rect.cpp @@ -15,35 +15,31 @@ #include "rect.h" //#include - Rect::Rect(): l(0), r(0), t(0), b(0) { } - Rect::Rect(double ll, double rr, double tt, double bb): l(ll), r(rr), t(tt), b(bb) { Normalize(); } - Rect::Rect(Point tl, Point br): l(tl.x), r(br.x), t(tl.y), b(br.y) { Normalize(); } - Rect & Rect::operator*=(double scale) { l *= scale; r *= scale; t *= scale; b *= scale; + return *this; } - Rect & Rect::operator|=(Rect r2) { //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); @@ -62,7 +58,6 @@ Rect & Rect::operator|=(Rect r2) return *this; } - void Rect::Normalize(void) { if (l > r) @@ -80,7 +75,6 @@ void Rect::Normalize(void) } } - void Rect::Translate(Point p) { l += p.x; @@ -89,7 +83,6 @@ void Rect::Translate(Point p) b += p.y; } - void Rect::Expand(double amt) { l -= amt; @@ -98,33 +91,37 @@ void Rect::Expand(double amt) b -= amt; } - double Rect::Width(void) { return r - l; } - double Rect::Height(void) { return t - b; } - bool Rect::Contains(Point p) { return ((p.x >= l) && (p.x <= r) && (p.y >= b) && (p.y <= t) ? true : false); } - Point Rect::TopLeft(void) { return Point(l, t); } +Point Rect::TopRight(void) +{ + return Point(r, t); +} + +Point Rect::BottomLeft(void) +{ + return Point(l, b); +} Point Rect::BottomRight(void) { return Point(r, b); } -