From 761de3879c5b4b3e0b7d2d9d30ced3aa56f8a39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20St=C3=B6ckl?= Date: Wed, 28 Aug 2019 19:05:11 +0200 Subject: added closepath support in SVG --- svgwrite.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'svgwrite.go') diff --git a/svgwrite.go b/svgwrite.go index d438393..7045199 100644 --- a/svgwrite.go +++ b/svgwrite.go @@ -29,6 +29,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) { var cx0, cy0, cx1, cy1 float64 var path []SVGBasicSegmentType var seg SVGBasicSegmentType + var startX, startY float64 sval := func(origin float64, arg int) float64 { return origin + scale*seg.Arg[arg] } @@ -48,6 +49,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) { switch seg.Cmd { case 'M': x, y = val(0) + startX, startY = x, y f.SetXY(x, y) case 'L': newX, newY = val(0) @@ -73,7 +75,7 @@ func (f *Fpdf) SVGBasicWrite(sb *SVGBasicType, scale float64) { f.Line(x, y, x, newY) y = newY case 'Z': - f.Line(x, y, originX, originY) + f.Line(x, y, startX, startY) default: f.SetErrorf("Unexpected path command '%c'", seg.Cmd) } -- cgit v1.2.1-24-ge1ad