From 4fc9681334bf42f3b8a3f374e4803f35bf2724e8 Mon Sep 17 00:00:00 2001 From: acspike Date: Mon, 30 Apr 2007 19:16:11 +0000 Subject: [PATCH] fix csp opening closed subpaths. this is generally a good thing but might cause some differences in visual result, especially in any effect that used the implicit curveto conversion of the closing Z segments as a feature. --- share/extensions/cubicsuperpath.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/share/extensions/cubicsuperpath.py b/share/extensions/cubicsuperpath.py index cc59905ab..a151084eb 100755 --- a/share/extensions/cubicsuperpath.py +++ b/share/extensions/cubicsuperpath.py @@ -22,6 +22,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import simplepath from math import * +class SuperSubpath(list): + def __init__(self, items=[]): + self.closed = False + list.__init__(self, items) + def close(self, state=True): + self.closed = state + def matprod(mlist): prod=mlist[0] for m in mlist[1:]: @@ -104,10 +111,8 @@ def CubicSuperPath(simplepath): for s in simplepath: cmd, params = s if cmd == 'M': - if last: - csp[subpath].append([lastctrl[:],last[:],last[:]]) subpath += 1 - csp.append([]) + csp.append(SuperSubpath()) subpathstart = params[:] last = params[:] lastctrl = params[:] @@ -141,11 +146,9 @@ def CubicSuperPath(simplepath): lastctrl = arcp[-1][0] csp[subpath]+=arcp[:-1] elif cmd == 'Z': - csp[subpath].append([lastctrl[:],last[:],last[:]]) + csp[subpath].close() last = subpathstart[:] lastctrl = subpathstart[:] - #append final superpoint - csp[subpath].append([lastctrl[:],last[:],last[:]]) return csp def unCubicSuperPath(csp): @@ -155,6 +158,11 @@ def unCubicSuperPath(csp): a.append(['M',subpath[0][1][:]]) for i in range(1,len(subpath)): a.append(['C',subpath[i-1][2][:] + subpath[i][0][:] + subpath[i][1][:]]) + try: + if subpath.closed: + a.append(['Z',[]]) + except: + pass return a def parsePath(d): -- 2.30.2