u02: Implement recursive fill tool

This commit is contained in:
Simon Bruder 2023-05-06 21:09:59 +02:00
parent 649d5da18a
commit c851767445

View file

@ -8,6 +8,7 @@
#include "bresenham_line_tool.h"
#include "canvas_buffer.h"
#include "dda_line_tool.h"
#include "recursive_fill_tool.h"
#include "util.h"
TEST_CASE("Transform Mirror") {
@ -179,3 +180,23 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
REQUIRE(all_sums_are_one);
}
TEST_CASE("Recursive fill 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);
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);
// just some samples, not very thorough
REQUIRE(canvas->get_pixel(15, 15));
REQUIRE(canvas->get_pixel(20, 20));
REQUIRE(canvas->get_pixel(25, 20));
REQUIRE_FALSE(canvas->get_pixel(9, 9));
REQUIRE_FALSE(canvas->get_pixel(30, 9));
REQUIRE_FALSE(canvas->get_pixel(19, 30));
}