add BinPack test

This commit is contained in:
Konstantin Käfer
2015-05-06 12:41:56 +02:00
committed by John Firebaugh
parent 8dd6da5b5e
commit 40b604448f
4 changed files with 62 additions and 1 deletions

View File

@@ -23,7 +23,11 @@ public:
if (width <= ref.w && height <= ref.h) {
if (smallest == free.end() || (ref.y <= rect.y && ref.x <= rect.x)) {
smallest = it;
} else {
// Our current "smallest" rect is already closer to 0/0.
}
} else {
// The rect in the free list is not big enough.
}
}

View File

@@ -12,10 +12,15 @@ struct Rect {
T originalW = 0, originalH = 0;
template <typename Number>
Rect operator *(Number value) const {
inline Rect operator *(Number value) const {
return Rect(x * value, y * value, w * value, h * value);
}
template <typename R>
inline bool operator==(const R& r) const {
return x == r.x && y == r.y && w == r.w && h == r.h;
}
inline bool hasArea() const { return w != 0 && h != 0; }
};
}