EmbeddedSvg

class visigoth.common.embedded_svg.EmbeddedSvg(content, width=512, height=512)

Create an embedded SVG

Parameters

content (str) – the SVG content as a string

Keyword Arguments
  • width (int) – width of the embedded SVG

  • height (int) – height of the embedded SVG

Example

Screenshot (Link to open SVG for interactive features):

../_images/example8.png

Source Code (Link to Github):


import os
import sys
import argparse

from visigoth.diagram import Diagram
from visigoth.common.embedded_svg import EmbeddedSvg
from visigoth.common.text import Text


svg = """<?xml version="1.0" encoding="utf-8"?>
<svg height="100" version="1.1" width="100" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <circle r="45" cx="50" cy="50" fill="orange" stroke="purple" stroke-width="10" />
</svg>
"""

if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    args = parser.parse_args()

    d = Diagram(fill="white")

    d.add(Text("Embedded SVG!"))
    d.add(EmbeddedSvg(svg,400,40))

    svg = d.draw()

    f = open(args.outpath, "wb")
    f.write(svg)
    f.close()