From 2e6d34aa5ab92f9ef16c1a872ab24e8b615a728f Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Tue, 6 Sep 2016 01:39:30 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20conversion=20of=20cubic=20B=C3=A9zier=20"?= =?UTF-8?q?curveto"=20commands=20into=20"shorthand/smooth=20curveto"=20com?= =?UTF-8?q?mands.=20When=20the=20preceeding=20path=20segment=20is=20a=20B?= =?UTF-8?q?=C3=A9zier=20curve,=20too,=20the=20first=20control=20point=20of?= =?UTF-8?q?=20the=20shorthand=20defaults=20to=20the=20mirrored=20version?= =?UTF-8?q?=20of=20the=20second=20control=20point=20of=20this=20preceeding?= =?UTF-8?q?=20path=20segment.=20Scour=20always=20assumed=20(0,0)=20as=20th?= =?UTF-8?q?e=20control=20point=20in=20this=20case=20which=20could=20result?= =?UTF-8?q?=20in=20modified=20path=20data=20(e.g.=20#91).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scour/scour.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scour/scour.py b/scour/scour.py index 754e5dd..fdae854 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -2193,7 +2193,13 @@ def cleanPath(element, options) : newPath.append( (cmd, lineTuples) ) # convert Bézier curve segments into s where possible elif cmd == 'c': - bez_ctl_pt = (0,0) + # set up the assumed bezier control point as the current point, i.e. (0,0) since we're using relative coords + bez_ctl_pt = (0, 0) + # however if the previous command was 's' the assumed control point is a reflection of the previous control point at the current point + if len(newPath): + (prevCmd, prevData) = newPath[-1] + if prevCmd == 's': + bez_ctl_pt = (prevData[-2]-prevData[-4], prevData[-1]-prevData[-3]) i = 0 curveTuples = [] while i < len(data):