···
-
if isinstance(v, defs.DrawingDef):
-
v = 'url(#{})'.format(v.id)
outputFile.write(' {}="{}"'.format(k,v))
···
def writeSvgDefs(self, idGen, isDuplicate, outputFile):
for defn in self.getSvgDefs():
if isDuplicate(defn): continue
defn.writeSvgElement(outputFile)
···
tags. This will not be called if hasContent is False. '''
raise RuntimeError('This element has no content')
-
return [v for v in self.args.values() if isinstance(v, defs.DrawingDef)]
if isinstance(other, type(self)):
return (self.TAG_NAME == other.TAG_NAME and
···
class Use(DrawingBasicElement):
''' A copy of another element
-
Specify the other element by its id: href='#otherElemId'. '''
def __init__(self, otherElem, x, y, **kwargs):
-
if isinstance(otherElem, str):
-
otherElemId = otherElem
-
if otherElem.id is None:
-
raise ValueError('otherElem must have an id')
-
otherElemId = otherElem.id
-
href = '#{}'.format(otherElemId)
-
super().__init__(xlink__href=href, x=x, y=y, **kwargs)
class Image(DrawingBasicElement):
''' A linked or embedded raster image '''
···
+
if isinstance(v, defs.DrawingElement):
+
v = 'url(#{})'.format(v.id)
outputFile.write(' {}="{}"'.format(k,v))
···
def writeSvgDefs(self, idGen, isDuplicate, outputFile):
for defn in self.getSvgDefs():
if isDuplicate(defn): continue
+
defn.writeSvgDefs(idGen, isDuplicate, outputFile)
defn.writeSvgElement(outputFile)
···
tags. This will not be called if hasContent is False. '''
raise RuntimeError('This element has no content')
+
return [v for v in self.args.values()
+
if isinstance(v, defs.DrawingElement)]
if isinstance(other, type(self)):
return (self.TAG_NAME == other.TAG_NAME and
···
class Use(DrawingBasicElement):
''' A copy of another element
+
The other element becomes an SVG def shared between all Use elements
def __init__(self, otherElem, x, y, **kwargs):
+
if isinstance(otherElem, str) and not otherElem.startswith('#'):
+
otherElem = '#' + otherElem
+
super().__init__(xlink__href=otherElem, x=x, y=y, **kwargs)
class Image(DrawingBasicElement):
''' A linked or embedded raster image '''