diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2015-09-16 21:46:22 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2015-09-16 21:46:22 +0000 |
| commit | a37006313230abab62a96554785f2f9286e24183 (patch) | |
| tree | 7ae5c8d1f9820d65bcd1089e8b868f8c395b06ee | |
| parent | fix for recent merge of ~mapreri/inkscape/typo (diff) | |
| download | inkscape-a37006313230abab62a96554785f2f9286e24183.tar.gz inkscape-a37006313230abab62a96554785f2f9286e24183.zip | |
Extensions. Interpolate: optionally use z-order instead of selection order (workaround for reversed selection order with live preview)
(bzr r14371)
| -rw-r--r-- | share/extensions/interp.inx | 1 | ||||
| -rwxr-xr-x | share/extensions/interp.py | 28 |
2 files changed, 21 insertions, 8 deletions
diff --git a/share/extensions/interp.inx b/share/extensions/interp.inx index cd5d32343..470d5dc10 100644 --- a/share/extensions/interp.inx +++ b/share/extensions/interp.inx @@ -9,6 +9,7 @@ <param name="method" type="int" min="1" max="2" _gui-text="Interpolation method:">2</param> <param name="dup" type="boolean" _gui-text="Duplicate endpaths">true</param> <param name="style" type="boolean" _gui-text="Interpolate style">false</param> + <param name="zsort" type="boolean" _gui-text="Use Z-order" _gui-description="Workaround for reversed selection order in Live Preview cycles">false</param> <effect> <object-type>path</object-type> <effects-menu> diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 459190c0e..d3a1f1468 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -16,7 +16,7 @@ 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 ''' -import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform +import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform, pathmodifier def numsegs(csp): return sum([len(p)-1 for p in csp]) @@ -103,6 +103,10 @@ class Interp(inkex.Effect): action="store", type="inkbool", dest="style", default=True, help="try interpolation of some style properties") + self.OptionParser.add_option("--zsort", + action="store", type="inkbool", + dest="zsort", default=True, + help="use z-order instead of selection order") def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' sp = self.unittouu(start[property]) @@ -122,7 +126,15 @@ class Interp(inkex.Effect): paths = {} styles = {} - for id in self.options.ids: + + if self.options.zsort: + # work around selection order swapping with Live Preview + sorted_ids = pathmodifier.zSort(self.document.getroot(),self.selected.keys()) + else: + # use selection order (default) + sorted_ids = self.options.ids + + for id in sorted_ids: node = self.selected[id] if node.tag ==inkex.addNS('path','svg'): paths[id] = cubicsuperpath.parsePath(node.get('d')) @@ -131,13 +143,13 @@ class Interp(inkex.Effect): if trans: simpletransform.applyTransformToPath(simpletransform.parseTransform(trans), paths[id]) else: - self.options.ids.remove(id) + sorted_ids.remove(id) - for i in range(1,len(self.options.ids)): - start = copy.deepcopy(paths[self.options.ids[i-1]]) - end = copy.deepcopy(paths[self.options.ids[i]]) - sst = copy.deepcopy(styles[self.options.ids[i-1]]) - est = copy.deepcopy(styles[self.options.ids[i]]) + for i in range(1,len(sorted_ids)): + start = copy.deepcopy(paths[sorted_ids[i-1]]) + end = copy.deepcopy(paths[sorted_ids[i]]) + sst = copy.deepcopy(styles[sorted_ids[i-1]]) + est = copy.deepcopy(styles[sorted_ids[i]]) basestyle = copy.deepcopy(sst) if basestyle.has_key('stroke-width'): basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0) |
