A very jank circle algorithm that overdraws many of the lines but mostly works.

This commit is contained in:
Zed A. Shaw 2024-12-19 19:02:27 -05:00
parent d4b6c35120
commit d916d1c383
5 changed files with 93 additions and 8 deletions

View file

@ -224,3 +224,25 @@ TEST_CASE("prototype line algorithm", "[matrix:line]") {
REQUIRE(f_found);
}
}
TEST_CASE("prototype circle algorithm", "[matrix:circle]") {
size_t width = Random::uniform<size_t>(10, 13);
size_t height = Random::uniform<size_t>(10, 15);
Map map(width,height);
// create a target for the paths
Point start{.x=map.width() / 2, .y=map.height()/2};
for(int radius = 2; radius < 5; radius++) {
// use an empty map
Matrix result = map.walls();
for(matrix::circle it{start, radius}; it.next();) {
println("y={}, x0={}, x1={}", it.y, it.x0, it.x1);
for(int i = it.x0; i < it.x1; i++) {
result[it.y][i] += 1;
}
}
matrix::dump("RESULT AFTER CIRCLE", result, start.x, start.y);
}
}