Package pySVG :: Module objecthelper :: Class ObjectHelper
[hide private]
[frames] | no frames]

Class ObjectHelper

source code

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.

Instance Methods [hide private]
 
createCircle(self, cx, cy, r, strokewidth=1, stroke='black', fill='none')
Creates a circle
source code
 
createEllipse(self, cx, cy, rx, ry, strokewidth=1, stroke='black', fill='none')
Creates an ellipse
source code
 
createRect(self, x, y, width, height, rx=None, ry=None, strokewidth=1, stroke='black', fill='none')
Creates a Rectangle
source code
 
createPolygon(self, points, strokewidth=1, stroke='black', fill='none')
Creates a Polygon
source code
 
createPolyline(self, points, strokewidth=1, stroke='black')
Creates a Polyline
source code
 
createLine(self, x1, y1, x2, y2, strokewidth=1, stroke="black")
Creates a line
source code
 
convertTupleArrayToPoints(self, arrayOfPointTuples)
Method used to convert an array of tuples (x,y) into a string suitable for createPolygon or createPolyline
source code
Method Details [hide private]

createCircle(self, cx, cy, r, strokewidth=1, stroke='black', fill='none')

source code 

Creates a circle

Parameters:
  • cx (string or int) - starting x-coordinate
  • cy (string or int) - starting y-coordinate
  • r (string or int) - radius
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
  • fill (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to fill the element (default: no filling)
Returns:
a circle object

createEllipse(self, cx, cy, rx, ry, strokewidth=1, stroke='black', fill='none')

source code 

Creates an ellipse

Parameters:
  • cx (string or int) - starting x-coordinate
  • cy (string or int) - starting y-coordinate
  • rx (string or int) - radius in x direction
  • ry (string or int) - radius in y direction
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
  • fill (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to fill the element (default: no filling)
Returns:
an ellipse object

createRect(self, x, y, width, height, rx=None, ry=None, strokewidth=1, stroke='black', fill='none')

source code 

Creates a Rectangle

Parameters:
  • x (string or int) - starting x-coordinate
  • y (string or int) - starting y-coordinate
  • width (string or int) - width of the rectangle
  • height (string or int) - height of the rectangle
  • rx (string or int) - For rounded rectangles, the x-axis radius of the ellipse used to round off the corners of the rectangle.
  • ry (string or int) - For rounded rectangles, the y-axis radius of the ellipse used to round off the corners of the rectangle.
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
  • fill (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to fill the element (default: no filling)
Returns:
a rect object

createPolygon(self, points, strokewidth=1, stroke='black', fill='none')

source code 

Creates a Polygon

Parameters:
  • points (string in the form "x1,y1 x2,y2 x3,y3") - all points relevant to the polygon
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
  • fill (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to fill the element (default: no filling)
Returns:
a polygon object

createPolyline(self, points, strokewidth=1, stroke='black')

source code 

Creates a Polyline

Parameters:
  • points (string in the form "x1,y1 x2,y2 x3,y3") - all points relevant to the polygon
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
Returns:
a polyline object

createLine(self, x1, y1, x2, y2, strokewidth=1, stroke="black")

source code 

Creates a line

Parameters:
  • x1 (string or int) - starting x-coordinate
  • y1 - starting y-coordinate
  • x2 - ending x-coordinate
  • y2 (string or int) - ending y-coordinate
  • strokewidth (string or int) - width of the pen used to draw
  • stroke (string (either css constants like "black" or numerical values like "#FFFFFF")) - color with which to draw the outer limits
Returns:
a line object

convertTupleArrayToPoints(self, arrayOfPointTuples)

source code 

Method used to convert an array of tuples (x,y) into a string suitable for createPolygon or createPolyline

Parameters:
  • arrayOfPointTuples (An array containing tuples eg.[(x1,y1),(x2,y2]) - All points needed to create the shape @return a string in the form "x1,y1 x2,y2 x3,y3"