summaryrefslogtreecommitdiffstats
path: root/share/extensions/handles.py
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2006-01-16 02:36:01 +0000
committermental <mental@users.sourceforge.net>2006-01-16 02:36:01 +0000
commit179fa413b047bede6e32109e2ce82437c5fb8d34 (patch)
treea5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /share/extensions/handles.py
downloadinkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz
inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'share/extensions/handles.py')
-rwxr-xr-xshare/extensions/handles.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/share/extensions/handles.py b/share/extensions/handles.py
new file mode 100755
index 000000000..a77b84ccc
--- /dev/null
+++ b/share/extensions/handles.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2005 Aaron Spike, aaron@ekips.org
+
+This program is free software; you can redistribute it and/or modify
+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
+'''
+import inkex, simplepath, simplestyle
+
+class Handles(inkex.Effect):
+ def effect(self):
+ for id, node in self.selected.iteritems():
+ if node.tagName == 'path':
+ p = simplepath.parsePath(node.attributes.getNamedItem('d').value)
+ a =[]
+ pen = None
+ subPathStart = None
+ for cmd,params in p:
+ if cmd == 'C':
+ a.extend([['M', params[:2]], ['L', pen],
+ ['M', params[2:4]], ['L', params[-2:]]])
+ if cmd == 'Q':
+ a.extend([['M', params[:2]], ['L', pen],
+ ['M', params[:2]], ['L', params[-2:]]])
+
+ if cmd == 'M':
+ subPathStart = params
+
+ if cmd == 'Z':
+ pen = subPathStart
+ else:
+ pen = params[-2:]
+
+ if len(a) > 0:
+ new = self.document.createElement('svg:path')
+ s = {'stroke-linejoin': 'miter', 'stroke-width': '1.0px',
+ 'stroke-opacity': '1.0', 'fill-opacity': '1.0',
+ 'stroke': '#000000', 'stroke-linecap': 'butt',
+ 'fill': 'none'}
+ new.setAttribute('style', simplestyle.formatStyle(s))
+ new.setAttribute('d', simplepath.formatPath(a))
+ node.parentNode.appendChild(new)
+
+e = Handles()
+e.affect()