#include "rect.h"
//#include <stdio.h>
-
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);
return *this;
}
-
void Rect::Normalize(void)
{
if (l > r)
}
}
-
void Rect::Translate(Point p)
{
l += p.x;
b += p.y;
}
-
void Rect::Expand(double amt)
{
l -= 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);
}
-