This commit is contained in:
furrtek
2016-01-31 09:34:24 +01:00
parent 29ec87a9ad
commit 44638e504b
166 changed files with 8700 additions and 3967 deletions

View File

@@ -115,23 +115,23 @@ struct Point {
}
constexpr Point(
Coord x,
Coord y
) : x { x },
y { y }
int x,
int y
) : x { static_cast<Coord>(x) },
y { static_cast<Coord>(y) }
{
}
Point operator-() const {
return { static_cast<Coord>(-x), static_cast<Coord>(-y) };
return { -x, -y };
}
Point operator+(const Point& p) const {
return { static_cast<Coord>(x + p.x), static_cast<Coord>(y + p.y) };
return { x + p.x, y + p.y };
}
Point operator-(const Point& p) const {
return { static_cast<Coord>(x - p.x), static_cast<Coord>(y - p.y) };
return { x - p.x, y - p.y };
}
Point& operator+=(const Point& p) {
@@ -171,10 +171,7 @@ private:
/* Clockwise rotate (in screen coordinates), with a gain in
* magnitude of sqrt(2).
*/
return {
static_cast<Coord>(x - y),
static_cast<Coord>(x + y)
};
return { x - y, x + y };
}
#endif
};
@@ -190,10 +187,10 @@ struct Size {
}
constexpr Size(
Dim w,
Dim h
) : w { w },
h { h }
int w,
int h
) : w { static_cast<Dim>(w) },
h { static_cast<Dim>(h) }
{
}
@@ -213,8 +210,8 @@ struct Rect {
}
constexpr Rect(
Coord x, Coord y,
Dim w, Dim h
int x, int y,
int w, int h
) : pos { x, y },
size { w, h }
{
@@ -228,35 +225,33 @@ struct Rect {
{
}
Coord top() const {
int top() const {
return pos.y;
}
Coord bottom() const {
int bottom() const {
return pos.y + size.h;
}
Coord left() const {
int left() const {
return pos.x;
}
Coord right() const {
int right() const {
return pos.x + size.w;
}
Dim width() const {
int width() const {
return size.w;
}
Dim height() const {
int height() const {
return size.h;
}
Point center() const {
return {
static_cast<Coord>(pos.x + size.w / 2),
static_cast<Coord>(pos.y + size.h / 2)
};
return { pos.x + size.w / 2, pos.y + size.h / 2 };
}
bool is_empty() const {