summaryrefslogtreecommitdiff
path: root/gerber
diff options
context:
space:
mode:
Diffstat (limited to 'gerber')
-rw-r--r--gerber/am_statements.py5
-rw-r--r--gerber/primitives.py11
-rw-r--r--gerber/render/cairo_backend.py2
-rw-r--r--gerber/render/rs274x_backend.py8
-rw-r--r--gerber/tests/golden/example_single_quadrant.gbr16
-rw-r--r--gerber/tests/test_cairo_backend.py6
-rw-r--r--gerber/tests/test_primitives.py4
7 files changed, 39 insertions, 13 deletions
diff --git a/gerber/am_statements.py b/gerber/am_statements.py
index 248542d..9c09085 100644
--- a/gerber/am_statements.py
+++ b/gerber/am_statements.py
@@ -1015,11 +1015,10 @@ class AMLowerLeftLinePrimitive(AMPrimitive):
def to_primitive(self, units):
# TODO I think I have merged this wrong
# Offset the primitive from macro position
- position = tuple([a + b for a , b in zip (position, self.lower_left)])
position = tuple([pos + offset for pos, offset in
- zip(position, (self.width/2, self.height/2))])
+ zip(self.lower_left, (self.width/2, self.height/2))])
# Return a renderable primitive
- return Rectangle(self.position, self.width, self.height,
+ return Rectangle(position, self.width, self.height,
level_polarity=self._level_polarity, units=units)
def to_gerber(self, settings=None):
diff --git a/gerber/primitives.py b/gerber/primitives.py
index 98b3e1c..d78c6d9 100644
--- a/gerber/primitives.py
+++ b/gerber/primitives.py
@@ -16,12 +16,14 @@
# limitations under the License.
+from itertools import combinations
import math
from operator import add
-from itertools import combinations
-
-from .utils import validate_coordinates, inch, metric, convex_hull, rotate_point, nearly_equal
+from .utils import validate_coordinates, inch, metric, convex_hull, rotate_point, nearly_equal
+
+
+
class Primitive(object):
""" Base class for all Cam file primitives
@@ -721,7 +723,8 @@ class Rectangle(Primitive):
def _abs_height(self):
return (math.cos(math.radians(self.rotation)) * self.height +
math.sin(math.radians(self.rotation)) * self.width)
-
+
+ @property
def axis_aligned_height(self):
return (self._cos_theta * self.height + self._sin_theta * self.width)
diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py
index 349640a..dc39607 100644
--- a/gerber/render/cairo_backend.py
+++ b/gerber/render/cairo_backend.py
@@ -21,7 +21,7 @@ except ImportError:
import cairocffi as cairo
import math
-from operator import mul, di
+from operator import mul, div
import tempfile
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index 5ab74f0..b4b4612 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -476,6 +476,14 @@ class Rs274xContext(GerberContext):
def _render_inverted_layer(self):
pass
+ def _new_render_layer(self):
+ # TODO Might need to implement this
+ pass
+
+ def _flatten(self):
+ # TODO Might need to implement this
+ pass
+
def dump(self):
"""Write the rendered file to a StringIO steam"""
statements = map(lambda stmt: stmt.to_gerber(self.settings), self.statements)
diff --git a/gerber/tests/golden/example_single_quadrant.gbr b/gerber/tests/golden/example_single_quadrant.gbr
new file mode 100644
index 0000000..b0a3166
--- /dev/null
+++ b/gerber/tests/golden/example_single_quadrant.gbr
@@ -0,0 +1,16 @@
+%FSLAX23Y23*%
+%MOIN*%
+%ADD10C,0.01*%
+G74*
+D10*
+%LPD*%
+G01X1100Y600D02*
+G03X700Y1000I-400J0D01*
+G03X300Y600I0J-400D01*
+G03X700Y200I400J0D01*
+G03X1100Y600I0J400D01*
+G01X300D02*
+X1100D01*
+X700Y200D02*
+Y1000D01*
+M02*
diff --git a/gerber/tests/test_cairo_backend.py b/gerber/tests/test_cairo_backend.py
index f358235..625a23e 100644
--- a/gerber/tests/test_cairo_backend.py
+++ b/gerber/tests/test_cairo_backend.py
@@ -182,6 +182,8 @@ def _test_render(gerber_path, png_expected_path, create_output_path = None):
with open(png_expected_path, 'rb') as expected_file:
expected_bytes = expected_file.read()
- assert_equal(expected_bytes, actual_bytes)
-
+ # Don't directly use assert_equal otherwise any failure pollutes the test results
+ equal = (expected_bytes == actual_bytes)
+ assert_true(equal)
+
return gerber
diff --git a/gerber/tests/test_primitives.py b/gerber/tests/test_primitives.py
index 261e6ef..e23d5f4 100644
--- a/gerber/tests/test_primitives.py
+++ b/gerber/tests/test_primitives.py
@@ -10,15 +10,13 @@ from .tests import *
def test_primitive_smoketest():
p = Primitive()
-<<<<<<< HEAD
try:
p.bounding_box
assert_false(True, 'should have thrown the exception')
except NotImplementedError:
pass
-=======
#assert_raises(NotImplementedError, p.bounding_box)
->>>>>>> 5476da8... Fix a bunch of rendering bugs.
+
p.to_metric()
p.to_inch()
try: