'''
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
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...
'''
# standard library
import copy
import math
import re
import random
# local library
import inkex
import cubicsuperpath
import bezmisc
import simplestyle
from simpletransform import *
####################################################################
##-- zOrder computation...
##-- this should be shipped out in a separate file. inkex.py?
sortedList=[]
break
return sortedList
##################################
#-- Selectionlists manipulation --
##################################
clones={}
#!!!--> should it be given an id?
#seems to work without this!?!
return(clones)
return(id)
return(aList)
#Hum... not very efficient if there are many clones of groups...
return aList
return newNode
else:
raise AssertionError, "Trying to follow empty xlink.href attribute."
if doReplace:
return newNode
else:
raise AssertionError, "Only clones can be unlinked..."
################################
#-- Object conversion ----------
################################
#FIXME: no exception anymore and sometimes just one
try:
except:
rx=0
ry=0
d ='M %f,%f '%(x+rx,y)
d+='L %f,%f '%(x+w-rx,y)
d+='L %f,%f '%(x+w,y+h-ry)
d+='L %f,%f '%(x+rx,y+h)
d+='L %f,%f '%(x,y+ry)
if nnt:
if doReplace:
return newnode
newp = []
if doReplace:
return newNode
else:
raise AssertionError
#--TODO: support other object types!!!!
#--TODO: make sure cubicsuperpath supports A and Q commands...
#remove inkscape attributes, otherwise any modif of 'd' will be discarded!
return node
else:
return None
newSelection={}
################################
#-- Action ----------
################################
#-- overwrite this method in subclasses...
#self.duplicateNodes(self.selected)
#self.expandGroupsUnlinkClones(self.selected, True)
p = cubicsuperpath.parsePath(d)
#do what ever you want with p!
'''
bpt is a base point and for v in vectors, v'=v-p is a tangent vector at bpt.
Defaults to identity!
'''
for v in vects:
#-- your transformations go here:
#x,y=bpt
#bpt[0]=f(x,y)
#bpt[1]=g(x,y)
#for v in vects:
# vx,vy=v
#
#-- !caution! y-axis is pointing downward!
for v in vects:
#self.duplicateNodes(self.selected)
p = cubicsuperpath.parsePath(d)
for sub in p:
#e = Diffeo()
#e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99