'''
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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.
'''
# standard library
import copy
import math
import re
import random
# third party
# local library
import inkex
import cubicsuperpath
import bezmisc
import pathmodifier
import simpletransform
sortedList=[]
break
return sortedList
'''
This function receives 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="if pattern is a group then randomly pick group members")
help="group pick mode (rand=random seq=sequentially)")
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")
help="duplicate pattern before deformation")
dest="tab",
help="The selected UI-tab when OK was pressed")
##first selected->pattern, all but first selected-> skeletons
#id = self.options.ids[-1]
#TODO: allow 4th option: duplicate the first copy and clone the next ones.
'''
Recieves an arc length l, and returns the index of the segment in self.skelcomp
containing the corresponding 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
'''
receives a length, and returns the coresponding point and tangent of self.skelcomp
if follow is set to false, returns only the translation
'''
i,t=self.lengthtotime(s)
else:
if follow:
else:
return mat
return
#center at (0,0)
#check if group and expand it
patternList = []
if self.options.grouppick and (self.patternNode.tag == inkex.addNS('g','svg') or self.patternNode.tag=='g') :
else :
#inkex.debug(patternList)
counter=0
#!!!!>----> TODO: really test if path is closed! end point==start point is not enough!
if n>0:
while s<=length:
#!!!--> should it be given an id?
#seems to work without this!?!
s+=dx
if __name__ == '__main__':
e = PathScatter()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99