From: Antonio Ospite Date: Tue, 26 Jun 2018 13:45:24 +0000 (+0200) Subject: svgwrite_diagram: implement the clear() method X-Git-Url: https://git.ao2.it/flexagon-toolkit.git/commitdiff_plain/8d7cf5faaf5ff39d5dac7153566840b02f2dda6a svgwrite_diagram: implement the clear() method --- diff --git a/src/diagram/svgwrite_diagram.py b/src/diagram/svgwrite_diagram.py index bf94541..b9e5a56 100755 --- a/src/diagram/svgwrite_diagram.py +++ b/src/diagram/svgwrite_diagram.py @@ -82,6 +82,15 @@ class SvgwriteDiagram(Diagram): self.svg = InkscapeDrawing(None, profile='full', size=(str(width) + "px", str(height) + "px")) self.active_group = self.svg + def clear(self): + # Reset the SVG object + self.svg.elements = [] + self.svg.add(self.svg.defs) + + rect = self.svg.rect((0, 0), ('100%', '100%')) + self._fill(rect, self.background) + self.svg.add(rect) + def save_svg(self, filename): self.svg.saveas(filename)