2013-03-10 18:49:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Gfx
|
|
|
|
{
|
|
|
|
|
|
|
|
struct Point
|
|
|
|
{
|
|
|
|
si32 x;
|
|
|
|
si32 y;
|
|
|
|
|
2013-03-13 23:11:27 +00:00
|
|
|
Point() : x(0), y(0) {};
|
2013-03-13 22:01:05 +00:00
|
|
|
Point(si32 _x, si32 _y) : x(_x), y(_y) {};
|
|
|
|
|
|
|
|
bool operator==(const Point &p) const
|
|
|
|
{
|
|
|
|
return (x == p.x) && (y == p.y);
|
|
|
|
}
|
|
|
|
bool operator!=(const Point &p) const
|
|
|
|
{
|
|
|
|
return !(*this == p);
|
|
|
|
}
|
|
|
|
Point& operator+=(const Point &p)
|
|
|
|
{
|
|
|
|
x += p.x;
|
|
|
|
y += p.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Point& operator-=(const Point &p)
|
|
|
|
{
|
|
|
|
x -= p.x;
|
|
|
|
y -= p.y;
|
|
|
|
return *this;
|
|
|
|
}
|
2013-03-10 18:49:30 +00:00
|
|
|
};
|
|
|
|
|
2013-03-13 22:01:05 +00:00
|
|
|
struct Rect : Point
|
2013-03-10 18:49:30 +00:00
|
|
|
{
|
2013-03-13 22:01:05 +00:00
|
|
|
ui32 w;
|
|
|
|
ui32 h;
|
|
|
|
|
|
|
|
Rect() : w(0), h(0) {};
|
|
|
|
Rect(const Point & lt) : Point(lt), w(0), h(0) {};
|
|
|
|
Rect(const Point & lt, const Point & sz) : Point(lt), w(sz.x), h(sz.y) {};
|
|
|
|
Rect(si32 _x, si32 _y, ui32 _w, ui32 _h) : Point(_x, _y), w(_w), h(_h) {};
|
|
|
|
|
|
|
|
Rect& operator=(const Point &p)
|
|
|
|
{
|
|
|
|
x = p.x;
|
|
|
|
y = p.y;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
si32 leftX() const { return x; };
|
|
|
|
si32 centerX() const { return x+w/2; };
|
|
|
|
si32 rightX() const { return x+w; };
|
|
|
|
si32 topY() const { return y; };
|
|
|
|
si32 centerY() const { return y+h/2; }
|
|
|
|
si32 bottomY() const { return y+h; };
|
|
|
|
|
|
|
|
//top left corner of this rect
|
|
|
|
Point topLeft() const { return *this; }
|
|
|
|
|
|
|
|
//top right corner of this rect
|
|
|
|
Point topRight() const { return Point(x+w, y); }
|
|
|
|
|
|
|
|
//bottom left corner of this rect
|
|
|
|
Point bottomLeft() const { return Point(x, y+h); }
|
|
|
|
|
|
|
|
//bottom right corner of this rect
|
|
|
|
Point bottomRight() const { return Point(x+w, y+h); }
|
|
|
|
|
2013-03-13 23:11:27 +00:00
|
|
|
//add x,y and copy w,h from p
|
2013-03-13 22:01:05 +00:00
|
|
|
void addOffs_copySize(const Rect &p);
|
2013-03-10 18:49:30 +00:00
|
|
|
|
2013-03-13 23:11:27 +00:00
|
|
|
//rect intersection
|
|
|
|
Rect Rect::operator&(const Rect &p) const;
|
2013-03-10 18:49:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Color transform matrix for: grayscale, clone, bloodlust, etc */
|
|
|
|
typedef float ColorMatrix[3][3];
|
|
|
|
|
|
|
|
}
|