rdkit.sping.SVG.pidSVG module

piddleSVG

This module implements an SVG PIDDLE canvas. In other words, this is a PIDDLE backend that renders into a SVG file.

Bits have been shamelessly cobbled from piddlePDF.py and/or piddlePS.py

Greg Landrum (greglandrum@earthlink.net) 3/10/2000

class rdkit.sping.SVG.pidSVG.SVGCanvas(size=(300, 300), name='SVGCanvas', includeXMLHeader=True, extraHeaderText='')

Bases: rdkit.sping.pid.Canvas

clear()
drawArc(x1, y1, x2, y2, theta1=0, extent=360, edgeColor=None, edgeWidth=None, fillColor=None, dash=None, **kwargs)
drawCurve(x1, y1, x2, y2, x3, y3, x4, y4, edgeColor=None, edgeWidth=None, fillColor=Color(-1.00, -1.00, -1.00), closed=0, dash=None, **kwargs)
drawEllipse(x1, y1, x2, y2, edgeColor=None, edgeWidth=None, fillColor=Color(-1.00, -1.00, -1.00), dash=None, **kwargs)
drawFigure(partList, edgeColor=None, edgeWidth=None, fillColor=None, closed=0, dash=None, **kwargs)

drawFigure(partList) – draws a complex figure partlist: a set of lines, curves, and arcs defined by a tuple whose first element is one of figureLine, figureArc, figureCurve and whose remaining 4, 6, or 8 elements are parameters.

drawImage(image, x1, y1, x2=None, y2=None, **kwargs)

to the best of my knowledge, the only real way to get an image into SVG is to read it from a file. So we’ll save out to a PNG file, then set a link to that in the SVG.

drawLine(x1, y1, x2, y2, color=None, width=None, dash=None, **kwargs)

Draw a straight line between x1,y1 and x2,y2.

drawPolygon(pointlist, edgeColor=None, edgeWidth=None, fillColor=Color(-1.00, -1.00, -1.00), closed=0, dash=None, **kwargs)

drawPolygon(pointlist) – draws a polygon pointlist: a list of (x,y) tuples defining vertices

drawString(s, x, y, font=None, color=None, angle=0, **kwargs)
flush()
fontAscent(font=None)
fontDescent(font=None)
save(file=None, format=None)

Hand hand this either a file= <filename> or file = <an open file object>. By default, I’ve made the fomrat extension be .svg. By default it saves the file to “self.name” + ‘.svg’

stringWidth(s, font=None)

Return the logical width of the string if it were drawn in the current font (defaults to self.font).

text()
rdkit.sping.SVG.pidSVG.dashtest()
rdkit.sping.SVG.pidSVG.test()
rdkit.sping.SVG.pidSVG.test2()
rdkit.sping.SVG.pidSVG.testit(canvas, s, x, y, font=None)