Package obitools :: Module SVGdraw
[hide private]
[frames] | no frames]

Module SVGdraw

source code

Use SVGdraw to generate your SVGdrawings.

SVGdraw uses an object model drawing and a method toXML to create SVG graphics
by using easy to use classes and methods usualy you start by creating a drawing eg

    d=drawing()
    #then you create a SVG root element
    s=svg()
    #then you add some elements eg a circle and add it to the svg root element
    c=circle()
    #you can supply attributes by using named arguments.
    c=circle(fill='red',stroke='blue')
    #or by updating the attributes attribute:
    c.attributes['stroke-width']=1
    s.addElement(c)
    #then you add the svg root element to the drawing
    d.setSVG(s)
    #and finaly you xmlify the drawing
    d.toXml()
    

this results in the svg source of the drawing, which consists of a circle
on a white background. Its as easy as that;)
This module was created using the SVG specification of www.w3c.org and the
O'Reilly (www.oreilly.com) python books as information sources. A svg viewer
is available from www.adobe.com


Version: 1.0

Classes [hide private]
  pathdata
class used to create a pathdata object which can be used for a path.
  SVGelement
SVGelement(type,attributes,elements,text,namespace,**args) Creates a arbitrary svg element and is intended to be subclassed not used on its own.
  tspan
ts=tspan(text='',**args)
  tref
tr=tref(link='',**args)
  spannedtext
st=spannedtext(textlist=[])
  rect
r=rect(width,height,x,y,fill,stroke,stroke_width,**args)
  ellipse
e=ellipse(rx,ry,x,y,fill,stroke,stroke_width,**args)
  circle
c=circle(x,y,radius,fill,stroke,stroke_width,**args)
  point
p=point(x,y,color)
  line
l=line(x1,y1,x2,y2,stroke,stroke_width,**args)
  polyline
pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args)
  polygon
pl=polyline([[x1,y1],[x2,y2],...],fill,stroke,stroke_width,**args)
  path
p=path(path,fill,stroke,stroke_width,**args)
  text
t=text(x,y,text,font_size,font_family,**args)
  textpath
tp=textpath(text,link,**args)
  pattern
p=pattern(x,y,width,height,patternUnits,**args)
  title
t=title(text,**args)
  description
d=description(text,**args)
  lineargradient
lg=lineargradient(x1,y1,x2,y2,id,**args)
  radialgradient
rg=radialgradient(cx,cy,r,fx,fy,id,**args)
  stop
st=stop(offset,stop_color,**args)
  style
st=style(type,cdata=None,**args)
  image
im=image(url,width,height,x,y,**args)
  cursor
c=cursor(url,**args)
  marker
m=marker(id,viewbox,refX,refY,markerWidth,markerHeight,**args)
  group
g=group(id,**args)
  symbol
sy=symbol(id,viewbox,**args)
  defs
d=defs(**args)
  switch
sw=switch(**args)
  use
u=use(link,x,y,width,height,**args)
  link
a=link(url,**args)
  view
v=view(id,**args)
  script
sc=script(type,type,cdata,**args)
  animate
an=animate(attribute,from,to,during,**args)
  animateMotion
an=animateMotion(pathdata,dur,**args)
  animateTransform
antr=animateTransform(type,from,to,dur,**args)
  animateColor
ac=animateColor(attribute,type,from,to,dur,**args)
  set
st=set(attribute,to,during,**args)
  svg
s=svg(viewbox,width,height,**args)
  drawing
d=drawing()
Functions [hide private]
file object
file(name, mode=..., buffering=...)
Open a file using the file() type, returns a file object.
 
_escape(data, entities={})
Escape &, <, and > in a string of data.
source code
 
_quoteattr(data, entities={})
Escape and quote an attribute value.
source code
 
_xypointlist(a)
formats a list of xy pairs
source code
 
_viewboxlist(a)
formats a tuple
source code
 
_pointlist(a)
formats a list of numbers
source code
Variables [hide private]
  __doc__ = """Use SVGdraw to generate your SVGdrawin...
  use_dom_implementation = 0
  True = 1
  False = 0
  __package__ = 'obitools'

Imports: exceptions, implementation, PrettyPrint, sys


Function Details [hide private]

file(name, mode=..., buffering=...)

 

Open a file using the file() type, returns a file object. This is the preferred way to open a file.

Returns: file object

_escape(data, entities={})

source code 

Escape &, <, and > in a string of data.

You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value.

_quoteattr(data, entities={})

source code 

Escape and quote an attribute value.

Escape &, <, and > in a string of data, then quote it for use as an attribute value. The " character will be escaped as well, if necessary.

You can escape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value.


Variables Details [hide private]

__doc__

Value:
"""Use SVGdraw to generate your SVGdrawings.

SVGdraw uses an object model drawing and a method toXML to create SVG \
graphics
by using easy to use classes and methods usualy you start by creating \
a drawing eg

    d=drawing()
...