u02: Implement non recursive fill tool

This commit is contained in:
Simon Bruder 2023-05-06 22:33:42 +02:00
parent c851767445
commit 625c257f3f

View file

@ -8,6 +8,7 @@
#include "bresenham_line_tool.h"
#include "canvas_buffer.h"
#include "dda_line_tool.h"
#include "non_recursive_fill_tool.h"
#include "recursive_fill_tool.h"
#include "util.h"
@ -181,16 +182,29 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
REQUIRE(all_sums_are_one);
}
TEST_CASE("Recursive fill simple") {
TEST_CASE("Fill (recursive and non recursive) simple") {
canvas_buffer *canvas = new canvas_buffer(100, 100);
bresenham_line_tool *tool_line = new bresenham_line_tool(*canvas);
recursive_fill_tool *tool = new recursive_fill_tool(*canvas);
recursive_fill_tool *tool_fill_recursive = new recursive_fill_tool(*canvas);
non_recursive_fill_tool *tool_fill_non_recursive =
new non_recursive_fill_tool(*canvas);
tool_base *tool_fill;
int tool_fill_idx = GENERATE(0, 1);
switch (tool_fill_idx) {
case 0:
tool_fill = tool_fill_recursive;
break;
case 1:
tool_fill = tool_fill_non_recursive;
break;
}
tool_line->draw(10, 10, 30, 10);
tool_line->draw(10, 10, 20, 30);
tool_line->draw(20, 30, 30, 10);
tool->draw(15, 15);
tool_fill->draw(15, 15);
// just some samples, not very thorough
REQUIRE(canvas->get_pixel(15, 15));