8#ifndef GALAXY_MATH_RECTPACK_HPP_
9#define GALAXY_MATH_RECTPACK_HPP_
14#include <SFML/Graphics/Rect.hpp>
44 void init(
const int width,
const int height)
noexcept;
56 std::optional<sf::IntRect>
pack(
const int width,
const int height)
noexcept;
61 void clear()
noexcept;
Rectangle 2D bin packing class.
void init(const int width, const int height) noexcept
Set starting width and height of rectangle.
std::optional< sf::IntRect > pack(const int width, const int height) noexcept
Pack a rectangle into the master rectangle.
int get_width() const noexcept
Get total width.
int m_width
The starting width of the rectangle.
~RectPack() noexcept
Destructor.
void clear() noexcept
Clear all data.
std::vector< sf::IntRect > m_free_rects
Free space in master rectangle.
int m_height
The starting width of the rectangle.
RectPack() noexcept
Constructor.
const std::vector< sf::IntRect > & get_free_space() const noexcept
Get free rectangles.
int get_height() const noexcept
Get total height.