rdkit.sping.pid module

PIDDLE (Plug-In Drawing, Does Little Else) 2D Plug-In Drawing System

Magnus Lie Hetland Andy Robinson Joseph J. Strout and others

February-March 1999

On coordinates: units are Big Points, approximately 1/72 inch. The origin is at the top-left, and coordinates increase down (y) and to the right (x).

class rdkit.sping.pid.AffineMatrix(init=None)

Bases: object

rotate(theta)

counter clockwise rotation in standard SVG/libart coordinate system

scale(sx, sy)
translate(tx, ty)
class rdkit.sping.pid.Canvas(size=(300, 300), name='PIDDLE')

Bases: object

This is the base class for a drawing canvas. The ‘plug-in renderers’ we speak of are really just classes derived from this one, which implement the various drawing methods.

arcPoints(x1, y1, x2, y2, startAng=0, extent=360)

Return a list of points approximating the given arc.

canUpdate()

Returns 1 if the drawing can be meaningfully updated over time (e.g., screen graphics), 0 otherwise (e.g., drawing to a file).

clear()

Call this to clear and reset the graphics context.

curvePoints(x1, y1, x2, y2, x3, y3, x4, y4)

Return a list of points approximating the given Bezier curve.

drawArc(x1, y1, x2, y2, startAng=0, extent=360, edgeColor=None, edgeWidth=None, fillColor=None, dash=None, **kwargs)

Draw a partial ellipse inscribed within the rectangle x1,y1,x2,y2, starting at startAng degrees and covering extent degrees. Angles start with 0 to the right (+x) and increase counter-clockwise. These should have x1<x2 and y1<y2.

drawCurve(x1, y1, x2, y2, x3, y3, x4, y4, edgeColor=None, edgeWidth=None, fillColor=None, closed=0, dash=None, **kwargs)

Draw a Bezier curve with control points x1,y1 to x4,y4.

drawEllipse(x1, y1, x2, y2, edgeColor=None, edgeWidth=None, fillColor=None, dash=None, **kwargs)

Draw an orthogonal ellipse inscribed within the rectangle x1,y1,x2,y2. These should have x1<x2 and y1<y2.

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)

Draw a PIL Image into the specified rectangle. If x2 and y2 are omitted, they are calculated from the image size.

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

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

drawLines(lineList, color=None, width=None, dash=None, **kwargs)

Draw a set of lines of uniform color and width. lineList: a list of (x1,y1,x2,y2) line coordinates.

drawMultiLineString(s, x, y, font=None, color=None, angle=0, **kwargs)

Breaks string into lines (on , ,

, or ), and calls drawString on each.

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

drawPolygon(pointlist) – draws a polygon pointlist: a list of (x,y) tuples defining vertices closed: if 1, adds an extra segment connecting the last point to the first

drawRect(x1, y1, x2, y2, edgeColor=None, edgeWidth=None, fillColor=None, dash=None, **kwargs)

Draw the rectangle between x1,y1, and x2,y2. These should have x1<x2 and y1<y2.

drawRoundRect(x1, y1, x2, y2, rx=8, ry=8, edgeColor=None, edgeWidth=None, fillColor=None, dash=None, **kwargs)

Draw a rounded rectangle between x1,y1, and x2,y2, with corners inset as ellipses with x radius rx and y radius ry. These should have x1<x2, y1<y2, rx>0, and ry>0.

drawString(s, x, y, font=None, color=None, angle=0, **kwargs)

Draw a string starting at location x,y.

flush()

Call this to indicate that any comamnds that have been issued but which might be buffered should be flushed to the screen

fontAscent(font=None)

Find the ascent (height above base) of the given font.

fontDescent(font=None)

Find the descent (extent below base) of the given font.

fontHeight(font=None)

Find the height of one line of text (baseline to baseline) of the given font.

getSize()
isInteractive()

Returns 1 if onClick, onOver, and onKey events are possible, 0 otherwise.

save(file=None, format=None)

For backends that can be save to a file or sent to a stream, create a valid file out of what’s currently been drawn on the canvas. Trigger any finalization here. Though some backends may allow further drawing after this call, presume that this is not possible for maximum portability

file may be either a string or a file object with a write method
if left as the default, the canvas’s current name will be used
format may be used to specify the type of file format to use as
well as any corresponding extension to use for the filename This is an optional argument and backends may ignore it if they only produce one file format.
setInfoLine(s)

For interactive Canvases, displays the given string in the ‘info line’ somewhere where the user can probably see it.

stringBox(s, font=None)
stringWidth(s, font=None)

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

class rdkit.sping.pid.Font(size=12, bold=0, italic=0, underline=0, face=None)

Bases: object

This class represents font typeface, size, and style.

class rdkit.sping.pid.StateSaver(canvas)

Bases: object

This is a little utility class for saving and restoring the default drawing parameters of a canvas. To use it, add a line like this before changing any of the parameters:

saver = StateSaver(myCanvas)

then, when “saver” goes out of scope, it will automagically restore the drawing parameters of myCanvas.

rdkit.sping.pid.getFileObject(file, openFlags='wb')

Common code for every Canvas.save() operation takes a string or a potential file object and assures that a valid fileobj is returned