svgwrite_diagram: proper support for stroke_width
authorAntonio Ospite <ao2@ao2.it>
Tue, 26 Jun 2018 13:46:14 +0000 (15:46 +0200)
committerAntonio Ospite <ao2@ao2.it>
Wed, 27 Jun 2018 13:16:52 +0000 (15:16 +0200)
Support stroke_width for all drawing operations that call the _stroke()
method, and remove ad-hoc support for draw_polygon_by_verts() and
draw_star_by_verts()

src/diagram/svgwrite_diagram.py

index b9e5a56..1da39a2 100755 (executable)
@@ -118,13 +118,14 @@ class SvgwriteDiagram(Diagram):
             element['stroke'] = stroke_color
             element['stroke-opacity'] = a
             element['stroke-linejoin'] = 'round'
             element['stroke'] = stroke_color
             element['stroke-opacity'] = a
             element['stroke-linejoin'] = 'round'
+            element['stroke-width'] = self.stroke_width
         else:
             element['stroke'] = 'none'
 
     def draw_polygon_by_verts(self, verts,
                               stroke_color=(0, 0, 0),
                               fill_color=None):
         else:
             element['stroke'] = 'none'
 
     def draw_polygon_by_verts(self, verts,
                               stroke_color=(0, 0, 0),
                               fill_color=None):
-        polygon = self.svg.polygon(verts, stroke_width=self.stroke_width)
+        polygon = self.svg.polygon(verts)
 
         self._fill(polygon, fill_color)
         self._stroke(polygon, stroke_color)
 
         self._fill(polygon, fill_color)
         self._stroke(polygon, stroke_color)
@@ -133,7 +134,7 @@ class SvgwriteDiagram(Diagram):
 
     def draw_star_by_verts(self, cx, cy, verts, stroke_color=(0, 0, 0)):
         for v in verts:
 
     def draw_star_by_verts(self, cx, cy, verts, stroke_color=(0, 0, 0)):
         for v in verts:
-            line = self.svg.line((cx, cy), v, stroke_width=self.stroke_width)
+            line = self.svg.line((cx, cy), v)
             self._stroke(line, stroke_color)
             self.add(line)
 
             self._stroke(line, stroke_color)
             self.add(line)