Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''draws lines between the vertices of two selected paths'''
- #!/usr/bin/env python
- '''
- Copyright (C) 2007
- 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 sys, os
- sys.path.append(os.path.dirname(sys.argv[0])) #?
- import inkex, simplepath, sys
- class StringBoard(inkex.Effect):
- def __init__(self):
- inkex.Effect.__init__(self)
- def setAttr(self, node, name, value):
- attr = node.ownerDocument.createAttribute(name)
- attr.value = value
- node.attributes.setNamedItem(attr)
- def effect(self):
- paths = []
- for id, node in self.selected.iteritems():
- if node.tag == 'path':
- paths.append(node)
- if len(paths) == 2:
- break
- sys.stderr.write('Found 2\n')
- if len(paths) == 2:
- pts = [simplepath.parsePath(paths[i].attributes.getNamedItem('d').value)
- for i in (0,1)]
- line = []
- for i in range(0, min(map(len, pts))):
- line += [('M', pts[0][i][1][-2:])]
- line += [('L', pts[1][i][1][-2:])]
- ele = paths[0].ownerDocument.createElement('path')
- paths[0].parentNode.appendChild(ele)
- self.setAttr(ele, 'd', simplepath.formatPath(line))
- self.setAttr(ele, 'style', 'fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;')
- e = StringBoard()
- e.affect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement