It's a bit strange to create a rectangular region and then loop over all its rectangles (which will always be one). Just adapt the above loops like `for (int x = 0; x < tiles->width(); ++x) {`.