summaryrefslogtreecommitdiff
path: root/gerbonara/cam.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-26 22:36:20 +0200
committerjaseg <git@jaseg.de>2023-04-26 22:36:20 +0200
commit8409fbb90835c61bd675dc0070ea38ac671540f8 (patch)
treea253ed064dbf6597d8939c980ea585013e6b4b88 /gerbonara/cam.py
parent9f74fad6a238836339d158d388f538ef0eae61bc (diff)
downloadgerbonara-8409fbb90835c61bd675dc0070ea38ac671540f8.tar.gz
gerbonara-8409fbb90835c61bd675dc0070ea38ac671540f8.tar.bz2
gerbonara-8409fbb90835c61bd675dc0070ea38ac671540f8.zip
Export flashes as svg <use> tags
Diffstat (limited to 'gerbonara/cam.py')
-rw-r--r--gerbonara/cam.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/gerbonara/cam.py b/gerbonara/cam.py
index d94175e..3c92441 100644
--- a/gerbonara/cam.py
+++ b/gerbonara/cam.py
@@ -291,21 +291,15 @@ class CamFile:
return setup_svg(tags, bounds, margin=margin, arg_unit=arg_unit, svg_unit=svg_unit,
pagecolor=bg, tag=tag)
- def svg_objects(self, svg_unit=MM, fg='black', bg='white', tag=Tag):
+ def svg_objects(self, svg_unit=MM, fg='black', bg='white', aperture_map={}, tag=Tag):
pl = None
for i, obj in enumerate(self.objects):
- #if isinstance(obj, go.Flash):
- # if pl:
- # tags.append(pl.to_svg(tag, fg, bg))
- # pl = None
-
- # mask_tags = [ prim.to_svg(tag, 'white', 'black') for prim in obj.to_primitives(unit=svg_unit) ]
- # mask_tags.insert(0, tag('rect', width='100%', height='100%', fill='black'))
- # mask_id = f'mask{i}'
- # tag('mask', mask_tags, id=mask_id)
- # tag('rect', width='100%', height='100%', mask='url(#{mask_id})', fill=fg)
-
- #else:
+ if isinstance(obj, go.Flash) and id(obj.aperture) in aperture_map:
+ yield tag('use', href='#'+aperture_map[id(obj.aperture)],
+ x=f'{svg_unit(obj.x, obj.unit):.3f}',
+ y=f'{svg_unit(obj.y, obj.unit):.3f}')
+
+ else:
for primitive in obj.to_primitives(unit=svg_unit):
if isinstance(primitive, gp.Line):
if not pl: