#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
from pysvg.pysvg import *
from pysvg.objecthelper import *
from pysvg.transformhelper import *
from pysvg.stylehelper import *
#actions not working
def createText(content, x,y, actions=None):
t=text(content,x,y)
return t
def createMainBorderAndTexts():
oh=ObjectHelper()
sh=StyleHelper()
elements=[]
r=oh.createRect("0", "0", "946", "626", strokewidth="2px", stroke="#00C", fill="#FFF")
elements.append(r)
sh.setFilling("#000")
sh.setFontSize("24px")
t=text("Objects and Effects in ...", 30, 40, style_dict=sh.getStyleDict())
elements.append(t)
sh=StyleHelper()
sh.setFontSize("13px")
t=text("[The red circle, explanation texts and textlinks WILL (but are not yet) connected to JavaScript.]", 360, 35, style_dict=sh.getStyleDict())
elements.append(t)
elements.append(createText("Rectangle",230,90))
elements.append(createText("Circle",230,180))
elements.append(createText("Ellipse",230,275))
elements.append(createText("Polygon",100,350))
elements.append(createText("Polyline",270,350))
elements.append(createText("Line",270,470))
elements.append(createText("Path",190,570))
elements.append(createText("flowing Text",800,550))
elements.append(createText("linear gradient",600,90))
elements.append(createText("radial gradient",600,170))
elements.append(createText("opacity",600,310))
elements.append(createText("filter",600,440))
elements.append(createText("animation",800,375))
elements.append(createText("pattern",600,550))
elements.append(createText("group + transformation",780,190))
elements.append(createText("external Picture",800,310))
elements.append(createText("Textlink",800,495))
return elements
"""
k
no-tspan with onmouse... Objekte und Effekte in SVG
k [Der rote Kreis, die Erklärungstexte und die Textlinks sind mit JavaScript-Funktionen verknüpft.]
nok © by Dr. Thomas Meinike 2002
nok TMs10kSVGDemo.svg
nok Text
Rechteck
Kreis
Ellipse
Polygon
Polylinie
Linie
Pfad
normaler Fließtext
linearer Gradient
radialer Gradient
Opazität (Durchlässigkeit)
Spezialfilter
Animation
Muster
Gruppe+Transformation
externes Bild
Textlink
"""
def createShapes():
oh=ObjectHelper()
sh=StyleHelper()
elements=[]
#rectangles
r=oh.createRect(30, 70, 80, 30, strokewidth='0',fill='#090')
elements.append(r)
r=oh.createRect(120, 70, 80, 30, strokewidth='2px', stroke='#00C', fill='#FFC')
elements.append(r)
#circles
c=oh.createCircle(60, 170, 30, strokewidth='0',fill='#F00')
#
elements.append(c)
c=oh.createCircle(150, 170, 30, strokewidth='2px', stroke='#000', fill='#FF0')
elements.append(c)
#ellipse
e=oh.createEllipse(60, 270, 30, 15, strokewidth='0',fill='#F00')
#
elements.append(e)
e=oh.createEllipse(150, 270, 30, 15, strokewidth='2px', stroke='#000', fill='#CCC')
elements.append(e)
#polygon
p=oh.createPolygon('60,370, 70,360, 80,400, 50,440, 40,330', strokewidth='2px', stroke='#000', fill='#FFF')
elements.append(p)
#line
l=oh.createLine(60,470,180,470, strokewidth='2px', stroke='#00C')
elements.append(l)
l=oh.createLine(200,470,260,400, strokewidth='2px', stroke='#F00')
elements.append(l)
#polyline
p=oh.createPolyline('250,325 200,345 250,365', strokewidth='2px', stroke='#090')
elements.append(p)
#opacity
sh=StyleHelper()
sh.setFilling('#00C')
sh.setFillOpacity(0.5)
c=circle(450, 290, 50, style_dict=sh.getStyleDict())
elements.append(c)
sh=StyleHelper()
sh.setFilling('#00C')
sh.setFillOpacity(0.2)
sh.setStroke('#00C')
sh.setStrokeOpacity(0.3)
c=circle(475, 325, 50, style_dict=sh.getStyleDict())
elements.append(c)
#group + transform
th=TransformHelper()
th.setRotation('-30')
g=Group(transform_dict=th.getTransformDict())
r=oh.createRect(620, 500, width='100', height='50', rx=10, ry=10, stroke='#F00',strokewidth='2px',fill='none')
g.addElement(r)
sh=StyleHelper()
sh.setFilling('none')
sh.setFontSize('36px')
sh.setStrokeWidth('1px')
sh.setStroke('#00C')
t=text('Text',635, 537,style_dict=sh.getStyleDict())
g.addElement(t)
elements.append(g)
return elements
"""
http://www.datenverdrahten.de
"""
def main():
svg=SVG("Main Test Screen", "Showing all main features that work as example", height="100%", width="100%", viewBox="0 0 950 630")
for element in createMainBorderAndTexts():
svg.addElement(element)
for element in createShapes():
svg.addElement(element)
print svg.getXML()
svg.saveSVG('c:\\test.svg')
if __name__ == '__main__':
main()