make sure thin walls are always visible

This commit is contained in:
Laura Klünder 2017-10-16 17:10:32 +02:00
parent 38a63c5a6a
commit 0dd94d7459
2 changed files with 9 additions and 3 deletions

View file

@ -31,8 +31,11 @@ def render_svg(level, miny, minx, maxy, maxx, scale=1):
spaces_geom = bbox.intersection(unary_union([s.geometry for s in level.spaces.all()]))
doors_geom = bbox.intersection(unary_union([d.geometry for d in level.doors.all()]))
doors_geom = doors_geom.difference(spaces_geom)
svg.add_geometry(spaces_geom, fill_color='#ffffff')
walls_geom = buildings_geom.difference(spaces_geom).difference(doors_geom)
svg.add_geometry(walls_geom, fill_color='#aaaaaa', stroke_px=0.5, stroke_color='#aaaaaa')
return svg.get_xml()

View file

@ -84,7 +84,8 @@ class SVGImage:
return defid
def add_geometry(self, geometry=None, fill_color=None, fill_opacity=None, opacity=None, filter=None,
stroke_width=0.0, stroke_color=None, stroke_opacity=None, stroke_linejoin=None, clip_path=None):
stroke_px=0.0, stroke_width=0.0, stroke_color=None, stroke_opacity=None, stroke_linejoin=None,
clip_path=None):
if geometry is not None:
if not geometry:
return
@ -97,7 +98,9 @@ class SVGImage:
element.set('fill', fill_color or 'none')
if fill_opacity:
element.set('fill-opacity', str(fill_opacity)[:4])
if stroke_width:
if stroke_px:
element.set('stroke-width', self._trim_decimals(str(stroke_px)))
elif stroke_width:
element.set('stroke-width', self._trim_decimals(str(stroke_width * self.scale)))
if stroke_color:
element.set('stroke', stroke_color)