diff options
author | jaseg <git@jaseg.de> | 2021-06-14 00:28:03 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-06-14 00:28:03 +0200 |
commit | 62ef8a1483c9fd3cbd11988db1bb3bf17d98d68b (patch) | |
tree | c6de87090c8e889938edd0523c042791f4979c52 | |
parent | 0b8e99f79a168c1899949b7466755b4f8e06bac3 (diff) | |
download | gerbonara-62ef8a1483c9fd3cbd11988db1bb3bf17d98d68b.tar.gz gerbonara-62ef8a1483c9fd3cbd11988db1bb3bf17d98d68b.tar.bz2 gerbonara-62ef8a1483c9fd3cbd11988db1bb3bf17d98d68b.zip |
Fix remaining cairo backend tests
* fix cairo backend handling of arcs in regions
-rw-r--r-- | gerbonara/gerber/render/cairo_backend.py | 4 | ||||
-rw-r--r-- | gerbonara/gerber/tests/golden/example_cutin.png | bin | 0 -> 6495 bytes | |||
-rw-r--r-- | gerbonara/gerber/tests/golden/example_level_holes.png | bin | 0 -> 9991 bytes | |||
-rw-r--r-- | gerbonara/gerber/tests/test_cairo_backend.py | 30 |
4 files changed, 13 insertions, 21 deletions
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 Binary files differnew file mode 100644 index 0000000..dfc996d --- /dev/null +++ b/gerbonara/gerber/tests/golden/example_cutin.png diff --git a/gerbonara/gerber/tests/golden/example_level_holes.png b/gerbonara/gerber/tests/golden/example_level_holes.png Binary files differnew file mode 100644 index 0000000..79bc2df --- /dev/null +++ b/gerbonara/gerber/tests/golden/example_level_holes.png 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(): |