|
|
|
@ -226,7 +226,7 @@ TEST_CASE("prototype line algorithm", "[matrix:line]") { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST_CASE("prototype circle algorithm", "[matrix:circle]") { |
|
|
|
|
for(int count = 0; count < 20; count++) { |
|
|
|
|
for(int count = 0; count < 2000; count++) { |
|
|
|
|
size_t width = Random::uniform<size_t>(10, 13); |
|
|
|
|
size_t height = Random::uniform<size_t>(10, 15); |
|
|
|
|
int pos_mod = Random::uniform<int>(-3,3); |
|
|
|
@ -238,14 +238,17 @@ TEST_CASE("prototype circle algorithm", "[matrix:circle]") { |
|
|
|
|
// use an empty map
|
|
|
|
|
Matrix result = map.walls(); |
|
|
|
|
|
|
|
|
|
for(matrix::circle it{start, radius}; it.next();) { |
|
|
|
|
for(matrix::circle it{result, start, radius}; it.next();) { |
|
|
|
|
for(int x = it.left; x < it.right; x++) { |
|
|
|
|
// println("top={}, bottom={}, center.y={}, dy={}, left={}, right={}, x={}, y={}", it.top, it.bottom, it.center.y, it.dy, it.left, it.right, x, it.y);
|
|
|
|
|
if(matrix::inbounds(result, x, it.y)) { |
|
|
|
|
// println("RESULT {},{}", matrix::width(result), matrix::height(result));
|
|
|
|
|
REQUIRE(it.y >= 0); |
|
|
|
|
REQUIRE(x >= 0); |
|
|
|
|
REQUIRE(it.y < int(matrix::height(result))); |
|
|
|
|
REQUIRE(x < int(matrix::width(result))); |
|
|
|
|
result[it.y][x] += 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// matrix::dump("RESULT AFTER CIRCLE", result, start.x, start.y);
|
|
|
|
|
} |
|
|
|
|