removed deprecation for clones in perspective

This commit is contained in:
leyghisbb 2020-08-30 11:33:47 +02:00
parent 253479da32
commit 928417c3a7
2 changed files with 14 additions and 22 deletions

View File

@ -3,7 +3,7 @@
<name>Clones In Perspective</name> <name>Clones In Perspective</name>
<id>fablabchemnitz.de.clonesperspective</id> <id>fablabchemnitz.de.clonesperspective</id>
<param max="256" name="num" type="int" gui-text="How many?">5</param> <param max="256" name="num" type="int" gui-text="How many?">5</param>
<param max="1.0" name="ratio" type="float" gui-text="relative size">0.9</param> <param max="0.9999" precision="4" name="ratio" type="float" gui-text="relative size">0.9999</param>
<effect> <effect>
<object-type>all</object-type> <object-type>all</object-type>
<effects-menu> <effects-menu>
@ -15,4 +15,4 @@
<script> <script>
<command location="inx" interpreter="python">fablabchemnitz_clonesperspective.py</command> <command location="inx" interpreter="python">fablabchemnitz_clonesperspective.py</command>
</script> </script>
</inkscape-extension> </inkscape-extension>

View File

@ -18,10 +18,9 @@ class clonesPerspectiveEffect(inkex.Effect):
if 1 != len(self.svg.selected) : if 1 != len(self.svg.selected) :
inkex.errormsg("Select exactly 1 thing. Group if necessary") inkex.errormsg("Select exactly 1 thing. Group if necessary")
sys.exit(1) sys.exit(1)
id = self.svg.selected[0].get('id') id = list(self.svg.selected.items())[0][0]
sel = self.svg.selected[id] sel = self.svg.selected[id]
dic = sel.attrib dic = sel.attrib
try : try :
tx = dic[inkex.addNS('transform-center-x','inkscape') ] tx = dic[inkex.addNS('transform-center-x','inkscape') ]
except KeyError : except KeyError :
@ -35,12 +34,11 @@ class clonesPerspectiveEffect(inkex.Effect):
inkex.errormsg("Center of rotation at center of object") inkex.errormsg("Center of rotation at center of object")
sys.exit(1) sys.exit(1)
for node in sel: bbox = sel.bounding_box()
width = node.bounding_box().right - node.bounding_box().left width = bbox.height
height = node.bounding_box().bottom - node.bounding_box().top height = bbox.width
cx = float(node.bounding_box().left) + 0.5 * width #Find center of selected object cx = float(bbox.left) + 0.5 * width #Find center of selected object
cy = float(node.bounding_box().top) + 0.5 * height #Find center of selected object cy = float(bbox.top) + 0.5 * height #Find center of selected object
tx = float(tx) tx = float(tx)
ty = float(ty) ty = float(ty)
crat = 1.0 crat = 1.0
@ -58,16 +56,10 @@ class clonesPerspectiveEffect(inkex.Effect):
inkex.addNS('href','xlink') : "#" + id, inkex.addNS('href','xlink') : "#" + id,
inkex.addNS('transform-center-x','inkscape') : str(tx), inkex.addNS('transform-center-x','inkscape') : str(tx),
inkex.addNS('transform-center-y','inkscape') : str(ty), inkex.addNS('transform-center-y','inkscape') : str(ty),
# "x" : "0", 'transform' : ("matrix(%f,0,0,%f,%f,%f)" % (crat, crat,(1. - crat)*(cx + otx), (1. - crat)*(cy - oty))),
# "y" : "0", "width" : "100%",
'transform' : ("matrix(%f,0,0,%f,%f,%f)" % "height" : "100%",
(crat, crat,(1. - crat)*(cx + otx), }
(1. - crat)*(cy - oty))), parent.insert(j, etree.Element('use', att))
#WHY Inkscape and SVG run +y in OPPOSITE directions is BEYOND me.
"width" : "100%",
"height" : "100%",
}
parent.insert(j, etree.Element('use', att) )
# Create effect instance and apply it. clonesPerspectiveEffect().run()
clonesPerspectiveEffect().run()