本文整理汇总了Python中CGAT.SVGdraw.svg方法的典型用法代码示例。如果您正苦于以下问题:Python SVGdraw.svg方法的具体用法?Python SVGdraw.svg怎么用?Python SVGdraw.svg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGAT.SVGdraw
的用法示例。
在下文中一共展示了SVGdraw.svg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: writeToFile
# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import svg [as 别名]
def writeToFile(self, outfile):
"""write svg image to file.
"""
self.finalizePlot()
self.mRoot = SVGdraw.drawing()
self.mDraw = SVGdraw.svg(
(0, 0, self.mPageWidth, self.mPageHeight), "100%", "100%")
kk = self.mElements.keys()
kk.sort()
kk.reverse()
for k in kk:
for e in self.mElements[k]:
self.mDraw.addElement(e)
self.mRoot.setSVG(self.mDraw)
tfile = tempfile.mktemp()
self.mRoot.toXml(tfile)
lines = open(tfile, "r").readlines()
outfile.write(string.join(lines, ""))
outfile.write("\n")
os.remove(tfile)
示例2: writeToFile
# 需要导入模块: from CGAT import SVGdraw [as 别名]
# 或者: from CGAT.SVGdraw import svg [as 别名]
def writeToFile(self, outfile):
"""write svg image to file.
"""
self.finalizePlot()
kk = self.mElements.keys()
kk.sort()
kk.reverse()
# make sure the image size is ok
min_x, min_y, max_x, max_y = 0, 0, 0, 0
for k in kk:
for e in self.mElements[k]:
for x in ('x', 'x2', 'x1'):
if x in e.attributes:
v = e.attributes[x]
min_x = min(min_x, v)
max_x = max(max_x, v)
for y in ('y', 'y2', 'y1'):
if y in e.attributes:
v = e.attributes[y]
min_y = min(min_y, v)
max_y = max(max_y, v)
min_x, min_y = int(math.floor(min_x)), int(math.floor(min_y))
max_x, max_y = int(math.floor(max_x)), int(math.floor(max_y))
for k in kk:
for e in self.mElements[k]:
for x in ('x', 'x2', 'x1'):
if x in e.attributes:
e.attributes[x] -= min_x
for x in ('y', 'y2', 'y1'):
if y in e.attributes:
e.attributes[y] -= min_y
# now add all the elements
self.mRoot = SVGdraw.drawing()
self.mDraw = SVGdraw.svg(
(0, 0, self.mPageWidth - min_x, self.mPageHeight - min_y), "100%", "100%")
for k in kk:
for e in self.mElements[k]:
self.mDraw.addElement(e)
self.mRoot.setSVG(self.mDraw)
tfile = tempfile.mktemp()
self.mRoot.toXml(tfile)
lines = open(tfile, "r").readlines()
outfile.write(string.join(lines, ""))
outfile.write("\n")
os.remove(tfile)