I think that the handling of the transform attribute needs some care.
1. getMatrix
translate and scale don't check if the optional argument for the y-Axis is present or not.
rotate doesn't hanle the axis of rotation (stationary point)
skewX and skewY are missing.
The pareser seems to rely on sax for splitting the transfortmations from the 'transform-list" (string) into the "tr" list.
To me that current parser does not seem suitable to handle lists with more than one transformation and transformations with a variable number of arguments.
2.
i saw some highly reused code:
Code: Select all
for i in range(len(self.grouptransform)):
print "applying group transform: ",self.grouptransform[-i-1]
sh = sh.transformGeometry(self.grouptransform[-i-1])
Code: Select all
for transformation in self.grouptransform[::-1]:
print "applying group transform: ",transformation
sh = sh.transformGeometry(transformation)
SAX seems to have Problems with CDATA in the xml code. (This is a bit more serious as is breaks parsing)
For testing i have modifiled some examples from the w3c and put them into one file.
Code: Select all
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs> <rect id="MyRect" x="0" y="0" width="60" height="10"/> </defs>
<rect x=".1" y=".1" width="99.8" height="29.8" fill="none" stroke="blue" stroke-width=".2" />
<use xlink:href="#MyRect" transform="translate(20,2.5) rotate(10)" />
<path class="bezierpath" d="M100,200 C100,100 250,100 250,200 S400,300 400,200" />
<rect class="Border" x="400" y="100" width="100" height="100" />
<polyline class="Connect" points="120,200 120,120" />
<polyline class="Connect" points="250,100 250,200" />
<polyline class="Connect" points="250,200 250,300" />
<polygon class="Connect" points="800,100 300,200 500,800" />
<ellipse transform="translate(900 200) rotate(-30)" rx="250" ry="100" fill="none" stroke="blue" stroke-width="20" />
<rect x="21" y="21" width="80" height="60" fill="none" stroke="blue" stroke-width="2"/>
<g transform="translate(-10,-20) scale(2) rotate(45) translate(5,10)"> <rect x="100" y="100" width="400" height="20" rx="10" fill="green" /> </g>
<rect x="200" y="300" width="100" height="100" rx="10" fill="green" />
<g transform="translate(700 450) rotate(-30)"> <rect x="0" y="0" width="400" height="200" rx="50" fill="none" stroke="purple" stroke-width="30" /></g>
<circle class="EndPoint" cx="100" cy="200" r="10" /><circle class="EndPoint" cx="250" cy="200" r="10" /><circle class="EndPoint" cx="400" cy="200" r="10" /><circle class="CtlPoint" cx="100" cy="100" r="10" /><circle class="CtlPoint" cx="250" cy="100" r="10" /><circle class="CtlPoint" cx="400" cy="300" r="10" /><circle class="AutoCtlPoint" cx="250" cy="300" r="9" />
<text class="Label" x="25" y="120">M100,200 C100,100 250,100 250,200</text>
<text class="Label" x="325" y="350" style="text-anchor:middle">S400,300 400,200</text>
<path d="M200,400 h-150 a150,150 0 1,0 150,-150 z" fill="red" stroke="blue" stroke-width="5" />
<path d="M275,375 v-150 a150,150 0 0,0 -150,150 z" fill="yellow" stroke="blue" stroke-width="5" />
<path d="M400,350 l 50,-25 a25,25 -30 0,1 50,-25 l 50,-25 a25,50 -30 0,1 50,-25 l 50,-25 a25,75 -30 0,1 50,-25 l 50,-25 a25,100 -30 0,1 50,-25 l 50,-25" fill="none" stroke="red" stroke-width="5" />
</svg>