[reportlab-users] svg rendering and groups
jonas at reportlab.com
Fri Jan 9 07:54:55 EST 2009
We had a closer look at Dinu's code and noticed that he is using
getCTM which returns the cumulative transformation matrix of the
current group and all its parents, while still outputting the parent
groups into the xml. Therefor transformations got applied twice or
more in nested groups.
Marcel's patch worked in a graphics POV because it serializing nested
groups. The patch below sets the non-cumulative transformation matrix
to each group, therefor preserving all the group information and still
producing the right graphics.
Can Dinu please review this, as he knows more about renderSVG.py than
we do. We can then apply this patch to our repository.
--- graphics/renderSVG.py (revision 3356)
+++ graphics/renderSVG.py (working copy)
@@ -655,7 +655,7 @@
if self.verbose: print "### begin _SVGRenderer.drawGroup"
currGroup = self._canvas.startGroup()
- a, b, c, d, e, f = self._tracker.getCTM()
+ a, b, c, d, e, f = self._tracker.getState()['transform']
for childNode in group.getContents():
if isinstance(childNode, UserNode):
node2 = childNode.provideNode()
On Sun, Oct 5, 2008 at 8:13 AM, Marcel Tromp <marcel_reportlab at tromp.org> wrote:
> Problem is that renderSVG assumes additive transforms while RL assumes
> absolute transforms for groups in groups.
> The patch below solves the problem. It surpresses transforms for group
> --- renderSVG.py 2008-10-04 22:37:44.791828000 -0700
> 2008-06-30 20:47:27.069418000 -0700
> @@ -661,19 +661,10 @@
> node2 = childNode.provideNode()
> node2 = childNode
> - if isinstance(node2, Group) == False:
> - self.drawNode(node2)
> + self.drawNode(node2)
> self._canvas.transform(a, b, c, d, e, f)
> - for childNode in group.getContents():
> - if isinstance(childNode, UserNode):
> - node2 = childNode.provideNode()
> - else:
> - node2 = childNode
> - if isinstance(node2, Group):
> - self.drawNode(node2)
> if self.verbose: print "### end _SVGRenderer.drawGroup"
> Andy Robinson wrote:
>> 2008/10/2 Dinu Gherman <gherman at darwin.in-berlin.de>:
>>> I was involved in writing ReportLab's renderSVG module (Robin,
>>> correct me, if I'm wrong), but I am no longer and I don't know
>>> how much RL supports or even uses this code nowadays.
>> Nobody here actually looks closely at the output.
>> We'd welcome both specific error messages and patches; I can be
>> certain they won't break any RL applications as we don't use SVG
>> at all.
>> - Andy
>> reportlab-users mailing list
>> reportlab-users at reportlab.com
> reportlab-users mailing list
> reportlab-users at reportlab.com
More information about the reportlab-users