From 62ef8a1483c9fd3cbd11988db1bb3bf17d98d68b Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 14 Jun 2021 00:28:03 +0200 Subject: Fix remaining cairo backend tests * fix cairo backend handling of arcs in regions --- gerbonara/gerber/render/cairo_backend.py | 4 +++ gerbonara/gerber/tests/golden/example_cutin.png | Bin 0 -> 6495 bytes .../gerber/tests/golden/example_level_holes.png | Bin 0 -> 9991 bytes gerbonara/gerber/tests/test_cairo_backend.py | 30 +++++++-------------- 4 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 gerbonara/gerber/tests/golden/example_cutin.png create mode 100644 gerbonara/gerber/tests/golden/example_level_holes.png diff --git a/gerbonara/gerber/render/cairo_backend.py b/gerbonara/gerber/render/cairo_backend.py index ff5e6cb..a7baf84 100644 --- a/gerbonara/gerber/render/cairo_backend.py +++ b/gerbonara/gerber/render/cairo_backend.py @@ -295,6 +295,10 @@ class GerberCairoContext(GerberContext): radius = self.scale[0] * prim.radius angle1 = prim.start_angle angle2 = prim.end_angle + + if angle1 == angle2: + # Make the angles slightly different otherwise Cario will draw nothing + angle2 -= 0.000000001 if prim.direction == 'counterclockwise': mask.ctx.arc(center[0], center[1], radius, angle1, angle2) diff --git a/gerbonara/gerber/tests/golden/example_cutin.png b/gerbonara/gerber/tests/golden/example_cutin.png new file mode 100644 index 0000000..dfc996d Binary files /dev/null and b/gerbonara/gerber/tests/golden/example_cutin.png differ diff --git a/gerbonara/gerber/tests/golden/example_level_holes.png b/gerbonara/gerber/tests/golden/example_level_holes.png new file mode 100644 index 0000000..79bc2df Binary files /dev/null and b/gerbonara/gerber/tests/golden/example_level_holes.png differ diff --git a/gerbonara/gerber/tests/test_cairo_backend.py b/gerbonara/gerber/tests/test_cairo_backend.py index c60e7a9..b8c9676 100644 --- a/gerbonara/gerber/tests/test_cairo_backend.py +++ b/gerbonara/gerber/tests/test_cairo_backend.py @@ -105,31 +105,19 @@ def test_render_overlapping_touching(): def test_render_overlapping_contour(): """Umaco example of D02 staring a second contour""" - _test_render( - "resources/example_overlapping_contour.gbr", - "golden/example_overlapping_contour.png", - ) + _test_render("resources/example_overlapping_contour.gbr", "golden/example_overlapping_contour.png") -def _DISABLED_test_render_level_holes(): +def test_render_level_holes(): """Umaco example of using multiple levels to create multiple holes""" - - # TODO This is clearly rendering wrong. I'm temporarily checking this in because there are more - # rendering fixes in the related repository that may resolve these. - _test_render( - "resources/example_level_holes.gbr", "golden/example_overlapping_contour.png" - ) + _test_render("resources/example_level_holes.gbr", "golden/example_level_holes.png", + autocrop_golden=True, auto_contrast=True, scale=50, max_delta=0.005) -def _DISABLED_test_render_cutin(): +def test_render_cutin(): """Umaco example of using a cutin""" - - # TODO This is clearly rendering wrong. - _test_render( - "resources/example_cutin.gbr", - "golden/example_cutin.png", - "/Users/ham/Desktop/cutin.png", - ) + _test_render("resources/example_cutin.gbr", "golden/example_cutin.png", + autocrop_golden=True, auto_contrast=True, max_delta=0.005) def test_render_fully_coincident(): @@ -284,11 +272,11 @@ def images_match(reference, output, max_delta, autocrop_golden=False, auto_contr print_stats('out pre proc', out) ref -= ref.min() - ref /= ref.max() + ref /= ref.max() + 1e-9 ref *= 255 out -= out.min() - out /= out.max() + out /= out.max() + 1e-9 out *= 255 def write_refout(): -- cgit