diff --git a/src/pack.cpp b/src/pack.cpp
index c328919..7828edb 100644
--- a/src/pack.cpp
+++ b/src/pack.cpp
@@ -64,12 +64,12 @@ std::optional pack(const Frame& in_frame,
}
std::cout << "[pack] max area: " << max_area << "\n";
int optimal_size = int(ceil(std::sqrt(max_area)));
- std::cout << "[pack] optimal image dimention: " << optimal_size << " x "
+ std::cout << "[pack] optimal image dimension: " << optimal_size << " x "
<< optimal_size << "\n";
// cf. subject: D < min(M, N )
const int max_size = std::min(in_frame.width, in_frame.height) - 1;
- std::cout << "[pack] maximum image dimention: " << max_size << " x "
+ std::cout << "[pack] maximum image dimension: " << max_size << " x "
<< max_size << "\n";
// We will try to fit all the rectangles in a given square of size S.
@@ -93,7 +93,8 @@ std::optional pack(const Frame& in_frame,
// If we don't have room in either dimension, we won't be able to
// pack within this size candidate.
- if (x + box.width >= size and next_row + box.height >= size) {
+ if (x + box.width - 1 >= size and
+ next_row + box.height - 1 >= size) {
std::cout << "[pack] -> no room left (last row height = "
<< size - y << ")\n";
room_left = false;
@@ -101,7 +102,7 @@ std::optional pack(const Frame& in_frame,
}
// If we cannot fit the rect on the right, we fit it below.
- if (x + box.width >= size) {
+ if (x + box.width - 1 >= size) {
std::cout
<< "[pack] -> cannot fit in current row (width left = "
<< size - x << ")\n";
@@ -120,7 +121,8 @@ std::optional pack(const Frame& in_frame,
box.x = x;
box.y = y;
x += box.width;
- std::cout << "[pack] -> fit in (" << x << ", " << y << ")\n";
+ std::cout << "[pack] -> fit in (" << box.x << ", " << box.y
+ << ")\n";
}
if (room_left) {