[reportlab-users] renderSVG & PolyLine

Dirk Datzert reportlab-users@reportlab.com
Sun, 07 Sep 2003 10:37:55 +0200


Hi all,

I had little trouble with Polylines and SVG representations:

Polylines will be rendered always with black fill color. (I think that
black was the last fill color before the Polyline was actually drawn?)
I looked at Shapes.py and found the Polylines should never be filled.
I looked at renderSVG.py and found that LINE_STYLES have always a fill
style. (Maybe this is correct for solid shapes only ?)
I set the fill explicit to None now in renderSVG.SVGCanvas.polyLine()

After that the black fill has gone away, but I expected lines of
stroke-width 1. They come out with stroke-width 0.125 which I set
elsewhere in the code before.
Setting stroke-width by hand to 1 doesn't changed anything, so I set
stroke-width to 1.1 and got my finally result.

Since this changes are hardcoded it is no good solution, but maybe
someone can have a solution for the real bug ?

Regards,
Dirk

renderSVG.py:

class SVGCanvas
..
    def polyLine(self, points):
        assert len(points) >= 1, 'Polyline must have 1 or more points'

        if self._strokeColor != None:
            self.setColor(self._strokeColor)
            pairs = []
            for i in xrange(len(points)):
                pairs.append("%f %f" % (points[i]))
            pts = string.join(pairs, ', ')
            self.setFillColor(None)        # set fill to 'none'
            self.setLineWidth(1.1)        # need to set stroke-width
greater than 1 ???
            polyline = transformNode(self.doc, "polyline",
                points=pts, style=self._formatStyle(LINE_STYLES))    #
this includes fill style ???
            self.currGroup.appendChild(polyline)