diff --git a/matrix.hpp b/matrix.hpp index ffd5e7b..9d8a4bb 100644 --- a/matrix.hpp +++ b/matrix.hpp @@ -333,13 +333,15 @@ namespace matrix { struct rectangle_t { int x; int y; + int top; int left; - int right; int width; int height; + int right; int bottom; rectangle_t(MAT &mat, size_t start_x, size_t start_y, size_t width, size_t height) : + top(start_y), left(start_x), width(width), height(height) @@ -368,17 +370,21 @@ namespace matrix { struct rando_rect_t { int x; int y; + int x_offset; + int y_offset; rectangle_t it; rando_rect_t(MAT &mat, size_t start_x, size_t start_y, size_t width, size_t height) : it{mat, start_x, start_y, width, height} { + x_offset = Random::uniform(0, int(width)); + y_offset = Random::uniform(0, int(height)); } bool next() { bool done = it.next(); - x = it.x; - y = it.y; + x = it.left + ((it.x + x_offset) % it.width); + y = it.top + ((it.y + y_offset) % it.height); return done; } };