=== modified file 'share/extensions/addnodes.py' --- share/extensions/addnodes.py 2011-11-21 20:58:06 +0000 +++ share/extensions/addnodes.py 2015-05-26 14:25:37 +0000 @@ -6,6 +6,7 @@ b) so that each segment is divided into a given number of equal segments Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -36,7 +37,9 @@ m4=tpoint(m1,m2,t) m5=tpoint(m2,m3,t) m=tpoint(m4,m5,t) - return [[sp1[0][:],sp1[1][:],m1], [m4,m,m5], [m3,sp2[1][:],sp2[2][:]]] + a = sp1[0][:] if sp1[0] != None else None + b = sp2[2][:] if sp2[2] != None else None + return [[a,sp1[1][:],m1], [m4,m,m5], [m3,sp2[1][:],b]] def cspbezsplitatlength(sp1, sp2, l = 0.5, tolerance = 0.001): bez = (sp1[1][:],sp1[2][:],sp2[0][:],sp2[1][:]) t = bezmisc.beziertatlength(bez, l, tolerance) @@ -88,29 +91,27 @@ #avg = total/numlengths(lens) #inkex.debug("average segment length: %s" % avg) - new = [] + totalnew = [] for sub in p: - new.append([sub[0][:]]) - i = 1 - while i <= len(sub)-1: - length = cspseglength(new[-1][-1], sub[i]) - - if self.options.method == 'bynum': - splits = self.options.segments - else: - splits = math.ceil(length/self.options.max) - - for s in xrange(int(splits),1,-1): - new[-1][-1], next, sub[i] = cspbezsplitatlength(new[-1][-1], sub[i], 1.0/s) - new[-1].append(next[:]) - new[-1].append(sub[i]) - i+=1 - - node.set('d',cubicsuperpath.formatPath(new)) + c, new, i = cubicsuperpath.closedness(sub), [sub[0][:]], 1 + while i <= len(sub): + j = i % len(sub) + if j > 0 or c > 0: + length = cspseglength(new[-1], sub[j]) + splits = self.options.segments if self.options.method == 'bynum' else math.ceil(length/self.options.max) + for s in xrange(int(splits),1,-1): + new[-1], next, sub[j] = cspbezsplitatlength(new[-1], sub[j], 1.0/s) + new.append(next[:]) + new.append(sub[j]) + i += 1 + if c > 0: + new[0][0] = new[-1][0][:] + del new[-1] + totalnew.append(new) + node.set('d',cubicsuperpath.formatPath(totalnew)) if __name__ == '__main__': e = SplitIt() e.affect() - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/convert2dashes.py' --- share/extensions/convert2dashes.py 2015-03-08 15:40:10 +0000 +++ share/extensions/convert2dashes.py 2015-05-26 09:54:16 +0000 @@ -5,6 +5,7 @@ Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org Copyright (C) 2009 Alvin Penner, penner@vaxxine.com +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -37,7 +38,9 @@ m4=tpoint(m1,m2,t) m5=tpoint(m2,m3,t) m=tpoint(m4,m5,t) - return [[sp1[0][:],sp1[1][:],m1], [m4,m,m5], [m3,sp2[1][:],sp2[2][:]]] + a = sp1[0][:] if sp1[0] != None else None + b = sp2[2][:] if sp2[2] != None else None + return [[a,sp1[1][:],m1], [m4,m,m5], [m3,sp2[1][:],b]] def cspbezsplitatlength(sp1, sp2, l = 0.5, tolerance = 0.001): bez = (sp1[1][:],sp1[2][:],sp2[0][:],sp2[1][:]) t = bezmisc.beziertatlength(bez, l, tolerance) @@ -53,45 +56,55 @@ def effect(self): for id, node in self.selected.iteritems(): if node.tag == inkex.addNS('path','svg'): - dashes = [] - offset = 0 + dashes, offset = [], 0 style = simplestyle.parseStyle(node.get('style')) if style.has_key('stroke-dasharray'): - if style['stroke-dasharray'].find(',') > 0: - dashes = [float (dash) for dash in style['stroke-dasharray'].split(',')] + dashes = [float(dash) for dash in style['stroke-dasharray'].split(',')] + if len(dashes) % 2: dashes.extend(dashes) if style.has_key('stroke-dashoffset'): offset = style['stroke-dashoffset'] if dashes: p = cubicsuperpath.parsePath(node.get('d')) - new = [] + totalnew = [] for sub in p: + new = [] idash = 0 dash = dashes[0] - length = float (offset) - while dash < length: - length = length - dash + length = float(offset) + while dash <= length: + length -= dash idash = (idash + 1) % len(dashes) dash = dashes[idash] + startrender = idash % 2 == 0 new.append([sub[0][:]]) i = 1 - while i < len(sub): - dash = dash - length - length = cspseglength(new[-1][-1], sub[i]) - while dash < length: - new[-1][-1], next, sub[i] = cspbezsplitatlength(new[-1][-1], sub[i], dash/length) - if idash % 2: # create a gap - new.append([next[:]]) - else: # splice the curve - new[-1].append(next[:]) - length = length - dash - idash = (idash + 1) % len(dashes) - dash = dashes[idash] - if idash % 2: - new.append([sub[i]]) - else: - new[-1].append(sub[i]) - i+=1 - node.set('d',cubicsuperpath.formatPath(new)) + while i <= len(sub): + j = i % len(sub) + dash -= length + if j > 0 or cubicsuperpath.closedness(sub) > 0: + length = cspseglength(new[-1][-1], sub[j]) + while dash < length: + new[-1][-1], next, sub[j] = cspbezsplitatlength(new[-1][-1], sub[j], dash/length) + if idash % 2: + new[-1][-1][2] = None + new.append([[None] + next[1:]]) + else: + new[-1].append(next[:]) + length -= dash + idash = (idash + 1) % len(dashes) + dash = dashes[idash] + if idash % 2: + if j > 0: + new.append([sub[j]]) + else: + new[-1].append(sub[j]) + i += 1 + if startrender and idash % 2 == 0: # Final node joining + new[-1][-1][2] = new[0][0][2][:] + new[-1].extend(new[0][1:]) + del new[0] + totalnew.extend(new) + node.set('d',cubicsuperpath.formatPath(totalnew)) del style['stroke-dasharray'] node.set('style', simplestyle.formatStyle(style)) if node.get(inkex.addNS('type','sodipodi')): @@ -103,5 +116,4 @@ e = SplitIt() e.affect() - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/cspsubdiv.py' --- share/extensions/cspsubdiv.py 2011-11-21 20:58:06 +0000 +++ share/extensions/cspsubdiv.py 2015-05-25 12:27:15 +0000 @@ -7,31 +7,29 @@ p1 = Point(p1x,p1y) p2 = Point(p2x,p2y) p3 = Point(p3x,p3y) - s1 = Segment(p0,p3) return max(s1.distanceToPoint(p1),s1.distanceToPoint(p2)) - def cspsubdiv(csp,flat): for sp in csp: subdiv(sp,flat) -def subdiv(sp,flat,i=1): +def subdiv(sp,flat,i=0): while i < len(sp): p0 = sp[i-1][1] p1 = sp[i-1][2] p2 = sp[i][0] p3 = sp[i][1] - - b = (p0,p1,p2,p3) - m = maxdist(b) - if m <= flat: + if p1 == None and p2 == None: i += 1 else: - one, two = beziersplitatt(b,0.5) - sp[i-1][2] = one[1] - sp[i][0] = two[2] - p = [one[2],one[3],two[1]] - sp[i:1] = [p] + b = (p0,p1,p2,p3) + m = maxdist(b) + if m <= flat: + i += 1 + else: + one, two = beziersplitatt(b,0.5) + sp[i-1][2], sp[i][0] = one[1], two[2] + sp[i:0] = [[one[2],one[3],two[1]]] # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/cubicsuperpath.py' --- share/extensions/cubicsuperpath.py 2014-03-27 01:33:44 +0000 +++ share/extensions/cubicsuperpath.py 2015-05-26 10:53:16 +0000 @@ -3,6 +3,7 @@ cubicsuperpath.py Copyright (C) 2005 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,7 +18,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - """ import simplepath from math import * @@ -83,9 +83,9 @@ p=[] for i in range(0,NbSectors+1,1): angle=start+i*dTeta - v1=[O[0]+cos(angle)-(-v)*sin(angle),O[1]+sin(angle)+(-v)*cos(angle)] - pt=[O[0]+cos(angle) ,O[1]+sin(angle) ] - v2=[O[0]+cos(angle)- v *sin(angle),O[1]+sin(angle)+ v *cos(angle)] + v1=[O[0]+cos(angle)+v*sin(angle),O[1]+sin(angle)-v*cos(angle)] + pt=[O[0]+cos(angle) ,O[1]+sin(angle) ] + v2=[O[0]+cos(angle)-v*sin(angle),O[1]+sin(angle)+v*cos(angle)] p.append([v1,pt,v2]) p[ 0][0]=p[ 0][1][:] p[-1][2]=p[-1][1][:] @@ -96,68 +96,79 @@ applymat(mat, pts[1]) applymat(mat, pts[2]) return(p) - + +# Point EQuality Within Error +def peqwe(a, b, e): return abs(a[0] - b[0]) <= e and abs(a[1] - b[1]) <= e def CubicSuperPath(simplepath): - csp = [] - subpath = -1 - subpathstart = [] - last = [] - lastctrl = [] + csp, spc = [], -1 for s in simplepath: - cmd, params = s + cmd, params = s if cmd == 'M': - if last: - csp[subpath].append([lastctrl[:],last[:],last[:]]) - subpath += 1 + spc += 1 csp.append([]) - subpathstart = params[:] - last = params[:] - lastctrl = params[:] + csp[spc].append([None, params[:], None]) + elif cmd == 'C': + csp[spc][-1][2] = params[:2] + csp[spc].append([params[2:4], params[4:], None]) elif cmd == 'L': - csp[subpath].append([lastctrl[:],last[:],last[:]]) - last = params[:] - lastctrl = params[:] - elif cmd == 'C': - csp[subpath].append([lastctrl[:],last[:],params[:2]]) - last = params[-2:] - lastctrl = params[2:4] + csp[spc][-1][2] = csp[spc][-1][1][:] + csp[spc].append([params[:], params[:], None]) + elif cmd == 'Z': + if peqwe(csp[spc][0][1], csp[spc][-1][1], 1e-8): + csp[spc][0][0] = csp[spc][-1][0][:] + csp[spc].pop() + else: csp[spc][0][0], csp[spc][-1][2] = csp[spc][0][1][:], csp[spc][-1][1][:] elif cmd == 'Q': - q0=last[:] - q1=params[0:2] - q2=params[2:4] - x0= q0[0] + q0, q1, q2 = csp[spc][-1][1][:], params[:2], params[2:] x1=1./3*q0[0]+2./3*q1[0] x2= 2./3*q1[0]+1./3*q2[0] - x3= q2[0] - y0= q0[1] y1=1./3*q0[1]+2./3*q1[1] y2= 2./3*q1[1]+1./3*q2[1] - y3= q2[1] - csp[subpath].append([lastctrl[:],[x0,y0],[x1,y1]]) - last = [x3,y3] - lastctrl = [x2,y2] + csp[spc][-1][2] = [x1, y1] + csp[spc].append([[x2, y2], q2, None]) elif cmd == 'A': - arcp=ArcToPath(last[:],params[:]) - arcp[ 0][0]=lastctrl[:] - last=arcp[-1][1] - lastctrl = arcp[-1][0] - csp[subpath]+=arcp[:-1] - elif cmd == 'Z': - csp[subpath].append([lastctrl[:],last[:],last[:]]) - last = subpathstart[:] - lastctrl = subpathstart[:] - #append final superpoint - csp[subpath].append([lastctrl[:],last[:],last[:]]) - return csp - + arcp = ArcToPath(csp[spc][-1][1][:], params[:]) + csp[spc][-1][2] = arcp[0][2] + csp[spc].append([arcp[1][0], arcp[1][1], None]) + return csp + +# Checks for the closedness of a simple path: +# 0 for open paths +# 1 for closed paths whose endpoints coincide (point Z) +# 2 for all others (line Z) +def closedness(sp): + if sp[0][0] != None and sp[-1][2] != None: + if peqwe(sp[0][0], sp[0][1], 1e-8) and peqwe(sp[-1][1], sp[-1][2], 1e-8): + return 2 + else: + return 1 + else: + return 0 + +# Simple path in CubicSuperPath: +# [[ B, n0, r0], +# [l1, n1, r1], <- left/preceding handle, node, right/following handle of node 1 +# [l2, n2, r2], ... +# [lk, nk, D ]] +# Open: B = D = None. +# Closed, endpoints near: last item deleted, B = lk. +# Otherwise: B = n0, D = nk. def unCubicSuperPath(csp): - a = [] + l = [] for subpath in csp: if subpath: - a.append(['M',subpath[0][1][:]]) + l.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][:]]) - return a + l.append(['C',subpath[i-1][2][:] + subpath[i][0][:] + subpath[i][1][:]]) + c = closedness(subpath) + if c > 0: + d = subpath[-1][2][:] + a = subpath[0][0][:] + b = subpath[0][1][:] + if c == 1: + l.append(['C', d + a + b]) + l.append(['Z', []]) + return l def parsePath(d): return CubicSuperPath(simplepath.parsePath(d)) @@ -165,5 +176,4 @@ def formatPath(p): return simplepath.formatPath(unCubicSuperPath(p)) - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/flatten.py' --- share/extensions/flatten.py 2010-11-17 02:12:56 +0000 +++ share/extensions/flatten.py 2015-05-25 13:36:27 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2006 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -33,18 +34,18 @@ cspsubdiv.cspsubdiv(p, self.options.flat) np = [] for sp in p: - first = True - for csp in sp: - cmd = 'L' - if first: - cmd = 'M' - first = False - np.append([cmd,[csp[1][0],csp[1][1]]]) - node.set('d',simplepath.formatPath(np)) + tmplist = [['L', csp[1]] for csp in sp] + tmplist[0][0] = 'M' + c = cubicsuperpath.closedness(sp) + if c > 0: + if c == 1: + tmplist.append(['L', sp[0][1]]) + tmplist.append(['Z', []]) + np.extend(tmplist) + node.set('d',simplepath.formatPath(np)) if __name__ == '__main__': e = MyEffect() e.affect() - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/pathalongpath.py' --- share/extensions/pathalongpath.py 2015-03-08 16:10:20 +0000 +++ share/extensions/pathalongpath.py 2015-05-26 12:07:31 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -48,9 +49,10 @@ for pathcomp in path: for ctl in pathcomp: for pt in ctl: - tmp=pt[0] - pt[0]=-pt[1] - pt[1]=-tmp + if pt != None: + tmp=pt[0] + pt[0]=-pt[1] + pt[1]=-tmp def offset(pathcomp,dx,dy): for ctl in pathcomp: === modified file 'share/extensions/pathmodifier.py' --- share/extensions/pathmodifier.py 2014-03-27 01:33:44 +0000 +++ share/extensions/pathmodifier.py 2015-05-26 12:06:51 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -275,8 +276,9 @@ Defaults to identity! ''' for v in vects: - v[0]-=bpt[0] - v[1]-=bpt[1] + if v != None: + v[0]-=bpt[0] + v[1]-=bpt[1] #-- your transformations go here: #x,y=bpt @@ -290,8 +292,9 @@ #-- !caution! y-axis is pointing downward! for v in vects: - v[0]+=bpt[0] - v[1]+=bpt[1] + if v != None: + v[0]+=bpt[0] + v[1]+=bpt[1] def effect(self): === modified file 'share/extensions/perspective.py' --- share/extensions/perspective.py 2014-03-27 01:33:44 +0000 +++ share/extensions/perspective.py 2015-05-26 12:17:46 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python """ Copyright (C) 2005 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -136,9 +137,9 @@ simpletransform.applyTransformToPath(mat, p) for subs in p: for csp in subs: - csp[0] = self.project_point(csp[0],m) csp[1] = self.project_point(csp[1],m) - csp[2] = self.project_point(csp[2],m) + if csp[0] != None: csp[0] = self.project_point(csp[0],m) + if csp[2] != None: csp[2] = self.project_point(csp[2],m) mat = voronoi2svg.Voronoi2svg().invertTransform(mat) simpletransform.applyTransformToPath(mat, p) path.set('d',cubicsuperpath.formatPath(p)) === modified file 'share/extensions/radiusrand.inx' --- share/extensions/radiusrand.inx 2010-09-06 18:55:37 +0000 +++ share/extensions/radiusrand.inx 2014-11-24 05:02:52 +0000 @@ -6,8 +6,8 @@ inkex.py - 10.0 - 10.0 + 10.0 + 10.0 true false true === modified file 'share/extensions/radiusrand.py' --- share/extensions/radiusrand.py 2010-11-17 02:12:56 +0000 +++ share/extensions/radiusrand.py 2015-05-25 13:37:03 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2005 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,20 +67,21 @@ for csp in subpath: if self.options.end: delta=randomize([0,0], self.options.radiusx, self.options.radiusy, self.options.norm) - csp[0][0]+=delta[0] - csp[0][1]+=delta[1] - csp[1][0]+=delta[0] - csp[1][1]+=delta[1] - csp[2][0]+=delta[0] - csp[2][1]+=delta[1] + csp[1][0]+=delta[0] + csp[1][1]+=delta[1] + if csp[0] != None: + csp[0][0]+=delta[0] + csp[0][1]+=delta[1] + if csp[2] != None: + csp[2][0]+=delta[0] + csp[2][1]+=delta[1] if self.options.ctrl: - csp[0]=randomize(csp[0], self.options.radiusx, self.options.radiusy, self.options.norm) - csp[2]=randomize(csp[2], self.options.radiusx, self.options.radiusy, self.options.norm) + if csp[0] != None: csp[0]=randomize(csp[0], self.options.radiusx, self.options.radiusy, self.options.norm) + if csp[2] != None: csp[2]=randomize(csp[2], self.options.radiusx, self.options.radiusy, self.options.norm) node.set('d',cubicsuperpath.formatPath(p)) if __name__ == '__main__': e = RadiusRandomize() e.affect() - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 === modified file 'share/extensions/rubberstretch.py' --- share/extensions/rubberstretch.py 2011-11-21 20:58:06 +0000 +++ share/extensions/rubberstretch.py 2015-05-26 12:12:48 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,9 +35,10 @@ def applyDiffeo(self,bpt,vects=()): for v in vects: - v[0]-=bpt[0] - v[1]-=bpt[1] - v[1]*=-1 + if v != None: + v[0]-=bpt[0] + v[1]-=bpt[1] + v[1]*=-1 bpt[1]*=-1 a=self.options.ratio/100 b=min(self.options.curve/100,0.99) @@ -50,13 +52,14 @@ bpt[0]=x0+x*sy bpt[1]=y0+y/sx for v in vects: - dx,dy=v - dXdx=sy - dXdy= x*2*b*y/h/h*2**(-a) - dYdx=-y*2*b*x/w/w*2**(-a)/sx/sx - dYdy=1/sx - v[0]=dXdx*dx+dXdy*dy - v[1]=dYdx*dx+dYdy*dy + if v != None: + dx,dy=v + dXdx=sy + dXdy= x*2*b*y/h/h*2**(-a) + dYdx=-y*2*b*x/w/w*2**(-a)/sx/sx + dYdy=1/sx + v[0]=dXdx*dx+dXdy*dy + v[1]=dYdx*dx+dYdy*dy #--spherify #s=((x*x+y*y)/(w*w+h*h))**(-a/2) @@ -68,9 +71,10 @@ # v[1]=( -a/2/(x*x+y*y)*2*x*y)*s*dx+(1-a/2/(x*x+y*y)*2*y*y)*s*dy for v in vects: - v[0]+=bpt[0] - v[1]+=bpt[1] - v[1]*=-1 + if v != None: + v[0]+=bpt[0] + v[1]+=bpt[1] + v[1]*=-1 bpt[1]*=-1 if __name__ == '__main__': === modified file 'share/extensions/simpletransform.py' --- share/extensions/simpletransform.py 2011-11-21 20:58:06 +0000 +++ share/extensions/simpletransform.py 2015-05-26 12:06:40 +0000 @@ -2,6 +2,7 @@ ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr Copyright (C) 2010 Alvin Penner, penner@vaxxine.com +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,7 +113,8 @@ for comp in path: for ctl in comp: for pt in ctl: - applyTransformToPoint(mat,pt) + if pt != None: + applyTransformToPoint(mat,pt) def fuseTransform(node): if node.get('d')==None: === modified file 'share/extensions/summersnight.py' --- share/extensions/summersnight.py 2014-03-27 01:33:44 +0000 +++ share/extensions/summersnight.py 2015-05-26 12:07:36 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python """ Copyright (C) 2005 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -112,9 +113,9 @@ simpletransform.applyTransformToPath(mat, p) for subs in p: for csp in subs: - csp[0] = self.trafopoint(csp[0]) csp[1] = self.trafopoint(csp[1]) - csp[2] = self.trafopoint(csp[2]) + if csp[0] != None: csp[0] = self.trafopoint(csp[0]) + if csp[2] != None: csp[2] = self.trafopoint(csp[2]) mat = voronoi2svg.Voronoi2svg().invertTransform(mat) simpletransform.applyTransformToPath(mat, p) path.set('d',cubicsuperpath.formatPath(p)) === modified file 'share/extensions/whirl.inx' --- share/extensions/whirl.inx 2010-09-06 18:55:37 +0000 +++ share/extensions/whirl.inx 2015-05-25 10:14:00 +0000 @@ -6,6 +6,7 @@ inkex.py 5.0 true + false path === modified file 'share/extensions/whirl.py' --- share/extensions/whirl.py 2011-11-21 20:58:06 +0000 +++ share/extensions/whirl.py 2015-05-25 13:37:00 +0000 @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2005 Aaron Spike, aaron@ekips.org +CSP-None conversion by Parcly Taxel (2015), reddeloostw@gmail.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,33 +30,44 @@ action="store", type="inkbool", dest="rotation", default=True, help="direction of rotation") + self.OptionParser.add_option("-p", "--pretty", + action="store", type="inkbool", + dest="pretty", default=False, + help="convert line segments into curves for pretty whirls") def effect(self): for id, node in self.selected.iteritems(): - rotation = -1 - if self.options.rotation == True: - rotation = 1 + rotation = 1 if self.options.rotation else -1 whirl = self.options.whirl / 1000 if node.tag == inkex.addNS('path','svg'): d = node.get('d') p = cubicsuperpath.parsePath(d) for sub in p: + if self.options.pretty: + for i in range(len(sub)): + a, b, c, d = sub[i][1], sub[i][0], sub[i - 1][2], sub[i - 1][1] + if b != None and c != None: + x = cubicsuperpath.peqwe(a, b, 1e-8) + y = cubicsuperpath.peqwe(c, d, 1e-8) + if x and y: + b[0], b[1] = (d[0] + 2 * a[0]) / 3, (d[1] + 2 * a[1]) / 3 + c[0], c[1] = (2 * d[0] + a[0]) / 3, (2 * d[1] + a[1]) / 3 for csp in sub: for point in csp: - point[0] -= self.view_center[0] - point[1] -= self.view_center[1] - dist = math.sqrt((point[0] ** 2) + (point[1] ** 2)) - if dist != 0: - a = rotation * dist * whirl - theta = math.atan2(point[1], point[0]) + a - point[0] = (dist * math.cos(theta)) - point[1] = (dist * math.sin(theta)) - point[0] += self.view_center[0] - point[1] += self.view_center[1] + if point != None: + point[0] -= self.view_center[0] + point[1] -= self.view_center[1] + dist = math.hypot(point[0], point[1]) + if dist != 0: + a = rotation * dist * whirl + theta = math.atan2(point[1], point[0]) + a + point[0] = dist * math.cos(theta) + point[1] = dist * math.sin(theta) + point[0] += self.view_center[0] + point[1] += self.view_center[1] node.set('d',cubicsuperpath.formatPath(p)) if __name__ == '__main__': e = Whirl() e.affect() - # vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99