def render_svg(self, grp, drawtype):
        """Render to svg"""
        drawer = getattr(self, f"render_{drawtype}", self.render_obsolete)
        if drawer is None:
            raise Exception("Unknown draw type: " + drawtype)

        canvas_width = (self.draw.col_count() + 2 * self.margin) * self.boxsize
        canvas_height = (self.draw.row_count() +
                         2 * self.margin) * self.boxsize

        # white background providing margin:
        rect = grp.add(Rectangle.new(0, 0, canvas_width, canvas_height))
        rect.style['stroke'] = 'none'
        rect.style['fill'] = "black" if self.invert_code else "white"

        qrg = grp.add(Group())
        qrg.style['stroke'] = 'none'
        qrg.style['fill'] = "white" if self.invert_code else "black"
        qrg.add(drawer())
 def render_obsolete(self):
     for row in range(self.draw.row_count()):
         for col in range(self.draw.col_count()):
             if self.draw.isDark(col, row):
                 x, y = self.get_svg_pos(col, row)
                 return Rectangle.new(x, y, self.boxsize, self.boxsize)