From 519331d368aba3d43cf2c121b14be130ed54ef35 Mon Sep 17 00:00:00 2001 From: popolon2 Date: Tue, 29 Jan 2008 00:23:07 +0000 Subject: [PATCH] Update JF Barraud scripts to work with actual SVN see https://bugs.launchpad.net/inkscape/+bug/182832 (interpolate is not modified, and new scatter scripts not added) --- share/extensions/pathalongpath.inx | 46 ++--- share/extensions/pathalongpath.py | 19 +- share/extensions/pathmodifier.py | 286 ++++++++++------------------ share/extensions/rubberstretch.py | 8 +- share/extensions/simpletransform.py | 164 ++++++++++++++++ 5 files changed, 308 insertions(+), 215 deletions(-) create mode 100644 share/extensions/simpletransform.py diff --git a/share/extensions/pathalongpath.inx b/share/extensions/pathalongpath.inx index ce489a9e2..3011f015a 100644 --- a/share/extensions/pathalongpath.inx +++ b/share/extensions/pathalongpath.inx @@ -1,38 +1,38 @@ <_name>Pattern along Path math.univ-lille1.barraud.pathdeform - pathmodifier.py - pathalongpath.py - inkex.py - This effect bends a pattern object along an arbitrary "skeleton" path. The pattern can be a path or a group of paths. First, select the pattern object; then add to selection the skeleton path; then call this effect. +pathmodifier.py +pathalongpath.py +inkex.py +This effect bends a pattern object along arbitrary "skeleton" paths. The pattern is the top most object in the selection. (groups of paths/shapes/clones... allowed) - - Single - Single, stretched - Repeated - Repeated, stretched - + + Single + Single, stretched + Repeated + Repeated, stretched + - - Snake - Ribbon - + + Snake + Ribbon + - 0.0 +0.0 - 0.0 - 0.0 +0.0 +0.0 - false - true +false +true - - - + + + - + diff --git a/share/extensions/pathalongpath.py b/share/extensions/pathalongpath.py index e49aadeb4..a8285b9f8 100644 --- a/share/extensions/pathalongpath.py +++ b/share/extensions/pathalongpath.py @@ -32,7 +32,7 @@ they move and rotate, deforming the pattern. ''' import inkex, cubicsuperpath, bezmisc -import pathmodifier +import pathmodifier,simpletransform import copy, math, re, random @@ -118,9 +118,16 @@ class PathAlongPath(pathmodifier.Diffeo): help="duplicate pattern before deformation") def prepareSelectionList(self): - ##first selected->pattern, all but first selected-> skeletons - id = self.options.ids[-1] + + idList=self.options.ids + idList=pathmodifier.zSort(self.document.getroot(),idList) + id = idList[-1] self.patterns={id:self.selected[id]} + +## ##first selected->pattern, all but first selected-> skeletons +## id = self.options.ids[-1] +## self.patterns={id:self.selected[id]} + if self.options.duplicate: self.patterns=self.duplicateNodes(self.patterns) self.expandGroupsUnlinkClones(self.patterns, True, True) @@ -203,7 +210,8 @@ class PathAlongPath(pathmodifier.Diffeo): self.options.repeat =True self.options.stretch=True - bbox=self.computeBBox(self.patterns) + bbox=simpletransform.computeBBox(self.patterns.values()) + if self.options.vertical: #flipxy(bbox)... bbox=(-bbox[3],-bbox[2],-bbox[1],-bbox[0]) @@ -233,12 +241,13 @@ class PathAlongPath(pathmodifier.Diffeo): xoffset=self.skelcomp[0][0]-bbox[0]+self.options.toffset yoffset=self.skelcomp[0][1]-(bbox[2]+bbox[3])/2-self.options.noffset + if self.options.repeat: NbCopies=max(1,int(round((length+self.options.space)/dx))) width=dx*NbCopies if not self.skelcompIsClosed: width-=self.options.space - bbox=bbox[0],bbox[0]+width,bbox[2],bbox[3] + bbox=bbox[0],bbox[0]+width, bbox[2],bbox[3] new=[] for sub in p: for i in range(0,NbCopies,1): diff --git a/share/extensions/pathmodifier.py b/share/extensions/pathmodifier.py index baa31fca2..a7e312ae0 100644 --- a/share/extensions/pathmodifier.py +++ b/share/extensions/pathmodifier.py @@ -16,117 +16,35 @@ 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 barraud@math.univ-lille1.fr + +This code defines a basic class (PathModifier) of effects whose purpose is +to somehow deform given objects: one common tasks for all such effect is to +convert shapes, groups, clones to paths. The class has several functions to +make this (more or less!) easy. +As an exemple, a second class (Diffeo) is derived from it, +to implement deformations of the form X=f(x,y), Y=g(x,y)... + +TODO: Several handy functions are defined, that might in fact be of general +interest and that should be shipped out in separate files... ''' import inkex, cubicsuperpath, bezmisc, simplestyle +from simpletransform import * import copy, math, re, random -def parseTransform(transf,mat=[[1.0,0.0,0.0],[0.0,1.0,0.0]]): - if transf=="": - return(mat) - result=re.match("(translate|scale|rotate|skewX|skewY|matrix)\(([^)]*)\)",transf) -#-- translate -- - if result.group(1)=="translate": - args=result.group(2).split(",") - dx=float(args[0]) - if len(args)==1: - dy=0.0 - else: - dy=float(args[1]) - matrix=[[1,0,dx],[0,1,dy]] -#-- scale -- - if result.groups(1)=="scale": - args=result.group(2).split(",") - sx=float(args[0]) - if len(args)==1: - sy=sx - else: - sy=float(args[1]) - matrix=[[sx,0,0],[0,sy,0]] -#-- rotate -- - if result.groups(1)=="rotate": - args=result.group(2).split(",") - a=float(args[0])*math.pi/180 - if len(args)==1: - cx,cy=(0.0,0.0) - else: - cx,cy=args[1:] - matrix=[[math.cos(a),-math.sin(a),cx],[math.sin(a),math.cos(a),cy]] -#-- skewX -- - if result.groups(1)=="skewX": - a=float(result.group(2))*math.pi/180 - matrix=[[1,math.tan(a),0],[0,1,0]] -#-- skewX -- - if result.groups(1)=="skewX": - a=float(result.group(2))*math.pi/180 - matrix=[[1,0,0],[math.tan(a),1,0]] -#-- matrix -- - if result.group(1)=="matrix": - a11,a21,a12,a22,v1,v2=result.group(2).split(",") - matrix=[[float(a11),float(a12),float(v1)],[float(a21),float(a22),float(v2)]] - - matrix=composeTransform(mat,matrix) - if result.end()