pathalongpath.py revision 519331d368aba3d43cf2c121b14be130ed54ef35
'''
Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
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
Quick description:
This script deforms an object (the pattern) along other paths (skeletons)...
The first selected object is the pattern
the last selected ones are the skeletons.
Imagine a straight horizontal line L in the middle of the bounding box of the pattern.
Consider the normal bundle of L: the collection of all the vertical lines meeting L.
Consider this as the initial state of the plane; in particular, think of the pattern
as painted on these lines.
Now move and bend L to make it fit a skeleton, and see what happens to the normals:
they move and rotate, deforming the pattern.
'''
import pathmodifier,simpletransform
'''
This function recieves a component of a 'cubicsuperpath' and returns two things:
The path subdivided in many straight segments, and an array containing the length of each segment.
We could work with bezier path as well, but bezier arc lengths are (re)computed for each point
in the deformed object. For complex paths, this might take a while.
'''
zero=0.000001
i=0
d=0
lengths=[]
while i<len(p)-1:
else:
i+=1
help="choose between wave or snake effect")
help="repeat the path to fit deformer's length")
help="reference path is vertical")
help="duplicate pattern before deformation")
def prepareSelectionList(self):
## ##first selected->pattern, all but first selected-> skeletons
## id = self.options.ids[-1]
## self.patterns={id:self.selected[id]}
def lengthtotime(self,l):
'''
Recieves an arc length l, and returns the index of the segment in self.skelcomp
containing the coresponding point, to gether with the position of the point on this segment.
If the deformer is closed, do computations modulo the toal length.
'''
if self.skelcompIsClosed:
if l<=0:
i=0
i+=1
return i, t
'''
The kernel of this stuff:
bpt is a base point and for v in vectors, v'=v-p is a tangent vector at bpt.
'''
i,t=self.lengthtotime(s)
else:
vx=0
else:
for v in vects:
else:
return
#flipxy(bbox)...
newp=[]
#!!!!>----> TODO: really test if path is closed! end point==start point is not enough!
if not self.skelcompIsClosed:
new=[]
for sub in p:
p=new
for sub in p:
for sub in p:
for sub in p:
flipxy(p)
newp+=p
e = PathAlongPath()
e.affect()