28 m_free_rects.emplace_back(0, 0, m_width, m_height);
34 std::optional<iRect> result = std::nullopt;
42 if (width <= space.width && height <= space.height)
45 result = std::make_optional<iRect>(space.x, space.y, width, height);
48 if (width == space.width && height == space.height)
54 else if (width == space.width)
58 space.height -= height;
60 else if (height == space.height)
69 iRect temp = {space.x + width, space.y, space.width - width, height};
72 space.height -= height;
int m_width
The starting width of the rectangle.
const std::vector< iRect > & get_free_space() const noexcept
Get free rectangles.
std::optional< iRect > pack(const int width, const int height)
Pack a rectangle into the master rectangle.
RectPack() noexcept
Constructor.
int m_height
The starting width of the rectangle.
void clear() noexcept
Clear all data.
int get_height() const noexcept
Get total height.
void init(const int width, const int height) noexcept
Set starting width and height of rectangle.
int get_width() const noexcept
Get total width.
~RectPack() noexcept
Destructor.
std::vector< iRect > m_free_rects
Free space in master rectangle.
Represents a rectangle object.