Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, *svgelements):
element = _transform.GroupElement(svgelements)
Element.__init__(self, element.root)
def __init__(self, dx, dy, size=8):
self.size = size
lines = self._gen_grid(dx, dy)
element = _transform.GroupElement(lines)
Element.__init__(self, element.root)
# Compose the views panel: total size is the width of
# any element (used the first here) and the sum of heights
fig = SVGFigure(width, heights[:nsvgs].sum())
yoffset = 0
for i, r in enumerate(roots):
r.moveto(0, yoffset, scale=scales[i])
if i == (nsvgs - 1):
yoffset = 0
else:
yoffset += heights[i]
# Group background and foreground panels in two groups
if fg_svgs:
newroots = [
GroupElement(roots[:nsvgs], {"class": "background-svg"}),
GroupElement(roots[nsvgs:], {"class": "foreground-svg"}),
]
else:
newroots = roots
fig.append(newroots)
fig.root.attrib.pop("width")
fig.root.attrib.pop("height")
fig.root.set("preserveAspectRatio", "xMidYMid meet")
with TemporaryDirectory() as tmpdirname:
out_file = Path(tmpdirname) / "tmp.svg"
fig.save(str(out_file))
# Post processing
svg = out_file.read_text().splitlines()
# Remove
def _transform(self, element, transform_list):
for t in transform_list:
element = GroupElement([element])
element.moveto(0, t['height'])
return element