builders

Module: builders

Inheritance diagram for pysvg.builders:

(C) 2008, 2009 Kerim Mansour For licensing information please refer to license.txt

Classes

ShapeBuilder

class pysvg.builders.ShapeBuilder

Helper class that creates commonly used objects and shapes with predefined styles and few but often used parameters. Used to avoid more complex coding for common tasks.

convertTupleArrayToPoints(arrayOfPointTuples)
Method used to convert an array of tuples (x,y) into a string suitable for createPolygon or createPolyline @type arrayOfPointTuples: An array containing tuples eg.[(x1,y1),(x2,y2] @param arrayOfPointTuples: All points needed to create the shape @return a string in the form “x1,y1 x2,y2 x3,y3”
createCircle(cx, cy, r, strokewidth=1, stroke='black', fill='none')
Creates a circle @type cx: string or int @param cx: starting x-coordinate @type cy: string or int @param cy: starting y-coordinate @type r: string or int @param r: radius @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @type fill: string (either css constants like “black” or numerical values like “#FFFFFF”) @param fill: color with which to fill the element (default: no filling) @return: a circle object
createEllipse(cx, cy, rx, ry, strokewidth=1, stroke='black', fill='none')
Creates an ellipse @type cx: string or int @param cx: starting x-coordinate @type cy: string or int @param cy: starting y-coordinate @type rx: string or int @param rx: radius in x direction @type ry: string or int @param ry: radius in y direction @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @type fill: string (either css constants like “black” or numerical values like “#FFFFFF”) @param fill: color with which to fill the element (default: no filling) @return: an ellipse object
createLine(x1, y1, x2, y2, strokewidth=1, stroke='black')
Creates a line @type x1: string or int @param x1: starting x-coordinate @type y1: string or int @param y1: starting y-coordinate @type x2: string or int @param x2: ending x-coordinate @type y2: string or int @param y2: ending y-coordinate @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @return: a line object
createPolygon(points, strokewidth=1, stroke='black', fill='none')
Creates a Polygon @type points: string in the form “x1,y1 x2,y2 x3,y3” @param points: all points relevant to the polygon @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @type fill: string (either css constants like “black” or numerical values like “#FFFFFF”) @param fill: color with which to fill the element (default: no filling) @return: a polygon object
createPolyline(points, strokewidth=1, stroke='black')
Creates a Polyline @type points: string in the form “x1,y1 x2,y2 x3,y3” @param points: all points relevant to the polygon @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @return: a polyline object
createRect(x, y, width, height, rx=None, ry=None, strokewidth=1, stroke='black', fill='none')
Creates a Rectangle @type x: string or int @param x: starting x-coordinate @type y: string or int @param y: starting y-coordinate @type width: string or int @param width: width of the rectangle @type height: string or int @param height: height of the rectangle @type rx: string or int @param rx: For rounded rectangles, the x-axis radius of the ellipse used to round off the corners of the rectangle. @type ry: string or int @param ry: For rounded rectangles, the y-axis radius of the ellipse used to round off the corners of the rectangle. @type strokewidth: string or int @param strokewidth: width of the pen used to draw @type stroke: string (either css constants like “black” or numerical values like “#FFFFFF”) @param stroke: color with which to draw the outer limits @type fill: string (either css constants like “black” or numerical values like “#FFFFFF”) @param fill: color with which to fill the element (default: no filling) @return: a rect object

StyleBuilder

class pysvg.builders.StyleBuilder(aStyle_dict=None)

Class to create a style string for those not familiar with svg attribute names. How to use it: 1) create an instance of StyleBuilder (builder=....) 2) set the attributes you want to have 3) create the shape (element) you want 4) call set_style on the element with “builder.getStyle()” as parameter

__init__(aStyle_dict=None)
getStyle()
setColorRendering(colorrendering)
setCurrentColor(color)
setDisplayAlign(displayalign)
setFillOpacity(fillopacity)
setFillRule(fillrule)
setFilling(fill)
setFontFamily(fontfamily)
setFontSize(fontsize)
setFontStyle(fontstyle)
setFontWeight(fontweight)
setImageRendering(imagerendering)
setLineIncrement(lineincrement)
setShapeRendering(shaperendering)
setSolidColor(solidcolor)
setSolidOpacity(solidopacity)
setStopColor(stopcolor)
setStopOpacity(stopopacity)
setStroke(stroke)
setStrokeDashArray(strokedasharray)
setStrokeDashOffset(strokedashoffset)
setStrokeLineCap(strikelinecap)
setStrokeLineJoin(strokelinejoin)
setStrokeMiterLimit(strokemiterlimit)
setStrokeOpacity(strokeopacity)
setStrokeWidth(strokewidth)
setTextAnchor(textanchor)
setTextRendering(textrendering)
setVectorEffect(vectoreffect)
setViewPortFill(viewportfill)
setViewPortOpacity(viewportfillopacity)

TransformBuilder

class pysvg.builders.TransformBuilder

Class to create a transform string for those not familiar with svg attribute names. How to use it: 1) create an instance of TransformBuilder (builder=....) 2) set the attributes you want to have 3) create the shape (element) you want 4) call set_transform on the element with “builder.getTransform()” as parameter

__init__()
getTransform()
setMatrix(a, b, c, d, e, f)
setRotation(rotate)
setScaling(x=None, y=None)
setSkewX(skewX)
setSkewY(skewY)
setTranslation(translate)

Table Of Contents

This Page