summaryrefslogtreecommitdiff
path: root/gerbonara
diff options
context:
space:
mode:
Diffstat (limited to 'gerbonara')
-rw-r--r--gerbonara/gerber/render/cairo_backend.py4
-rw-r--r--gerbonara/gerber/tests/golden/example_cutin.pngbin0 -> 6495 bytes
-rw-r--r--gerbonara/gerber/tests/golden/example_level_holes.pngbin0 -> 9991 bytes
-rw-r--r--gerbonara/gerber/tests/test_cairo_backend.py30
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
new file mode 100644
index 0000000..dfc996d
--- /dev/null
+++ b/gerbonara/gerber/tests/golden/example_cutin.png
Binary files 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
--- /dev/null
+++ b/gerbonara/gerber/tests/golden/example_level_holes.png
Binary files 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():