summaryrefslogtreecommitdiff
path: root/gerber/render/rs274x_backend.py
diff options
context:
space:
mode:
authorGarret Fick <garret@ficksworkshop.com>2016-07-24 22:08:31 +0800
committerGarret Fick <garret@ficksworkshop.com>2016-07-24 22:08:31 +0800
commit965d3ce23b92f8aff1063debd6d3364de15791fe (patch)
tree304ac755578479554ed812da87c782e9f6772582 /gerber/render/rs274x_backend.py
parent7cd6acf12670f3773113f67ed2acb35cb21c32a0 (diff)
downloadgerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.tar.gz
gerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.tar.bz2
gerbonara-965d3ce23b92f8aff1063debd6d3364de15791fe.zip
Add more tests for rendering to PNG. Start adding tests for rendering to Gerber format. Changed definition of no hole to use None instead of 0 so we can differentiate when writing to Gerber format. Makde polygon use hole diameter instead of hole radius to match other primitives
Diffstat (limited to 'gerber/render/rs274x_backend.py')
-rw-r--r--gerber/render/rs274x_backend.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/gerber/render/rs274x_backend.py b/gerber/render/rs274x_backend.py
index 15e9154..5ab74f0 100644
--- a/gerber/render/rs274x_backend.py
+++ b/gerber/render/rs274x_backend.py
@@ -1,9 +1,17 @@
+"""Renders an in-memory Gerber file to statements which can be written to a string
+"""
+from copy import deepcopy
+try:
+ from cStringIO import StringIO
+except(ImportError):
+ from io import StringIO
+
from .render import GerberContext
from ..am_statements import *
from ..gerber_statements import *
from ..primitives import AMGroup, Arc, Circle, Line, Obround, Outline, Polygon, Rectangle
-from copy import deepcopy
+
class AMGroupContext(object):
'''A special renderer to generate aperature macros from an AMGroup'''
@@ -467,4 +475,13 @@ class Rs274xContext(GerberContext):
def _render_inverted_layer(self):
pass
+
+ def dump(self):
+ """Write the rendered file to a StringIO steam"""
+ statements = map(lambda stmt: stmt.to_gerber(self.settings), self.statements)
+ stream = StringIO()
+ for statement in statements:
+ stream.write(statement + '\n')
+
+ return stream
\ No newline at end of file