2008-04-24 11:07:47 -07:00
|
|
|
#include "geom.h"
|
|
|
|
|
2008-06-21 10:23:00 -07:00
|
|
|
rect rectFromPointAndSize(point p, size s)
|
|
|
|
{
|
|
|
|
rect r;
|
|
|
|
r.topLeft = p;
|
|
|
|
r.bottomRight.x = p.x + s.x;
|
|
|
|
r.bottomRight.y = p.y + s.y;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-04-24 11:07:47 -07:00
|
|
|
bool pointInRect(point p, rect r)
|
|
|
|
{
|
|
|
|
return (r.topLeft.x < p.x
|
|
|
|
&& r.bottomRight.x > p.x
|
|
|
|
&& r.topLeft.y < p.y
|
|
|
|
&& r.bottomRight.y > p.y);
|
|
|
|
}
|
2008-04-26 06:22:48 -07:00
|
|
|
|
2008-04-27 08:14:42 -07:00
|
|
|
point pointAdd(point p, point q)
|
|
|
|
{
|
|
|
|
point r;
|
|
|
|
r.x = p.x + q.x;
|
|
|
|
r.y = p.y + q.y;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|