fixed clones in perspective to work with InkScape 1.1dev/1.2dev

This commit is contained in:
Mario Voigt 2021-04-09 10:36:29 +02:00
parent 707341e04d
commit bcddf5c489

View File

@ -11,27 +11,24 @@ class clonesPerspectiveEffect(inkex.EffectExtension):
self.arg_parser.add_argument('--ratio', type = float, default = 0.9, help = 'Ratio of size of nearest neighbor to first. Must be < 1')
def effect(self):
svg = self.document.getroot()
num = int( self.options.num )
ratio = float( self.options.ratio)
if 1 != len(self.svg.selected) :
inkex.errormsg("Select exactly 1 thing. Group if necessary")
if len(self.svg.selected) != 1:
inkex.errormsg("Select exactly 1 thing. If necessary, group your items before.")
sys.exit(1)
id = list(self.svg.selected.items())[0][0]
sel = self.svg.selected[id]
dic = sel.attrib
xpath = list(self.svg.selected.items())[0][0]
sel = self.svg.selected[xpath]
id = sel.get('id')
try :
tx = dic[inkex.addNS('transform-center-x','inkscape') ]
tx = sel.attrib[inkex.addNS('transform-center-x','inkscape')]
except KeyError:
tx = '0.'
try :
ty = dic[inkex.addNS('transform-center-y','inkscape') ]
ty = sel.attrib[inkex.addNS('transform-center-y','inkscape')]
except KeyError:
ty = '0.'
if float(tx) == 0. and float(ty) == 0. :
inkex.errormsg("Center of rotation at center of object")
inkex.errormsg("Center of rotation ist at the center of object. Please move the center first.")
sys.exit(1)
bbox = sel.bounding_box()
@ -47,10 +44,10 @@ class clonesPerspectiveEffect(inkex.EffectExtension):
parent = sel.getparent()
j = parent.index(sel)
for i in range(num) :
crat *= ratio
tx *= ratio
ty *= ratio
for i in range(self.options.num) :
crat *= self.options.ratio
tx *= self.options.ratio
ty *= self.options.ratio
att = {
"id" : self.svg.get_unique_id("clone" + id),
inkex.addNS('href','xlink') : "#" + id,