diff options
Diffstat (limited to '')
-rw-r--r-- | rtgrpblib_draw_linear_bezier.c | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/rtgrpblib_draw_linear_bezier.c b/rtgrpblib_draw_linear_bezier.c index bf9d41e..a2af58f 100644 --- a/rtgrpblib_draw_linear_bezier.c +++ b/rtgrpblib_draw_linear_bezier.c @@ -127,24 +127,65 @@ static RASTER *raster; static RASTER *refraster; +#ifdef ROWWISE_RESET_INKLEVEL static void -check_draw_linear_bezier(double x1, double y1, double x2, double y2) +draw_right_edge_shadow(double x1, double y1, double x2, double y2) +{ + if (raster->draftness <= 0) + return; + + if (x1 >= 10.0 && x2 >= 10.0) { + draw_linear_bezier_reference(raster, x1, y1, x2, y2); + + } else if (x1 >= 10.0) { + y2 = y2 + (10.0 - x2) * (y2 - y1) / (x2 - x1); + x2 = 10.0; + draw_linear_bezier_reference(raster, x1, y1, x2, y2); + + } else if (x2 >= 10.0) { + y1 = y1 + (10.0 - x1) * (y2 - y1) / (x2 - x1); + x1 = 10.0; + draw_linear_bezier_reference(raster, x1, y1, x2, y2); + } +} +#endif + + +static void +proper_check_draw_linear_bezier(double x1, double y1, double x2, double y2) { size_t i; + alarm(5); rtgrpblib_draw_linear_bezier(raster, x1, y1, x2, y2); +#ifdef ROWWISE_RESET_INKLEVEL + draw_right_edge_shadow(x1, y1, x2, y2); +#endif + alarm(5); draw_linear_bezier_reference(refraster, x1, y1, x2, y2); + alarm(0); + for (i = 0; i < 100; i++) { - ASSERT(intolerant_eq(raster->cells[i].cell_coverage, refraster->cells[i].cell_coverage)); - ASSERT(intolerant_eq(raster->cells[i].opposite_coverage, refraster->cells[i].opposite_coverage)); + ASSERT(eq(raster->cells[i].cell_coverage, refraster->cells[i].cell_coverage)); + ASSERT(eq(raster->cells[i].opposite_coverage, refraster->cells[i].opposite_coverage)); } rtgrpblib_reset_raster(raster, 10, 10); rtgrpblib_reset_raster(refraster, 10, 10); } +static void +check_draw_linear_bezier(double x1, double y1, double x2, double y2) +{ + proper_check_draw_linear_bezier(floor(x1), floor(y1), floor(x2), floor(y2)); + proper_check_draw_linear_bezier(floor(x1), y1, floor(x2), y2); + proper_check_draw_linear_bezier(x1, floor(y1), x2, floor(y2)); + proper_check_draw_linear_bezier(x1, y1, x2, y2); +} + + static double frand(double a, double b) { @@ -169,26 +210,26 @@ main(void) ASSERT(refraster); srand((unsigned)(uintptr_t)raster); - for (i = 0; i < 10000UL; i++) { -#ifndef ROWWISE_RESET_INKLEVEL + for (i = 0; i < 50000UL; i++) { x1 = frand(-5, 15); y1 = frand(-5, 15); x2 = frand(-5, 15); y2 = frand(-5, 15); -#else - /* TODO add tests the support higher upper bound */ - x1 = frand(0, 10); /* TODO fix lower bound */ - y1 = frand(-5, 15); - x2 = frand(-5, 10); - y2 = frand(-5, 15); -#endif check_draw_linear_bezier(x1, y1, x2, y2); check_draw_linear_bezier(x1, x1, x2, x2); + check_draw_linear_bezier(x1, y1, x2, y1); check_draw_linear_bezier(x1, x2, x2, x1); + check_draw_linear_bezier(x1, y1, x1, y2); + check_draw_linear_bezier(x1, x1, x1, x1); + raster->draftness = -1; + check_draw_linear_bezier(x1, y1, x2, y2); + check_draw_linear_bezier(x1, x1, x2, x2); check_draw_linear_bezier(x1, y1, x2, y1); + check_draw_linear_bezier(x1, x2, x2, x1); check_draw_linear_bezier(x1, y1, x1, y2); - /* TODO test with zero draftness */ + check_draw_linear_bezier(x1, x1, x1, x1); + raster->draftness = 0.5; } free(raster); |