interp.py revision fc481aa6c2cef966e6f6da908090287f1e7f8807
'''
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
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
'''
return pointdistance(sp1[1], sp1[2]) + pointdistance(sp1[2], sp2[0]) + pointdistance(sp2[0], sp2[1])
total = 0
lengths = []
total += l
return retval
def parsecolor(c):
r,g,b = '0','0','0'
if c[:1]=='#':
if len(c)==4:
r,g,b = c[1:2],c[2:3],c[3:4]
elif len(c)==7:
r,g,b = c[1:3],c[3:5],c[5:7]
return r,g,b
help="values other than zero give non linear interpolation")
help="number of interpolation steps")
help="method of interpolation")
help="duplicate endpaths")
help="try interpolation of some style properties")
help="use z-order instead of selection order")
if exponent>= 0:
else:
paths = {}
styles = {}
# work around selection order swapping with Live Preview
else:
# use selection order (default)
for id in sorted_ids:
if trans:
else:
#prepare for experimental style tweening
'stroke-width':'1.0', 'stroke':'none', 'fill':'none'}
if isnotplain(sst['stroke']) or isnotplain(est['stroke']) or (sst['stroke']=='none' and est['stroke']=='none'):
if isnotplain(sst['fill']) or isnotplain(est['fill']) or (sst['fill']=='none' and est['fill']=='none'):
if dostroke:
if dofill:
#subdivide both paths into segments of relatively equal lengths
lengths = {}
t = 0
for l in sp:
t += l / stotal
lengths[t] += 1
t = 0
for l in sp:
t += l / etotal
lengths[t] += -1
t = 0
s = [[]]
if not start[0]:
for l in sp:
pt = t
t += l / stotal
t = 0
e = [[]]
if not end[0]:
for l in sp:
pt = t
t += l / etotal
start = s[:]
end = e[:]
else:
#which path has fewer segments?
#swap shortest first
if lengthdiff > 0:
#subdivide the shorter path
maxlen = 0
subpath = 0
segment = 0
subpath = y
segment = z
#if swapped, swap them back
if lengthdiff > 0:
#break paths so that corresponding subpaths have an equal number of segments
s = [[]]
e = [[]]
elif end[0]:
elif start[0]:
else:
#create an interpolated path for each interval
interp = []
#process subpaths
break
#process superpoints
break
#process points
break
#remove final subpath if empty.
if not interp[-1]:
del interp[-1]
#basic style tweening
if dostroke:
if dofill:
if __name__ == '__main__':
e = Interp()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99