This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-0.92-deprecated/fablabchemnitz_netting.py

64 lines
2.3 KiB
Python
Raw Normal View History

2019-11-14 20:05:10 +01:00
#!/usr/bin/env python
'''
netting.py
Sunabe kazumichi 2010/3/4
http://dp48069596.lolipop.jp/
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
this program nets in the line.
'''
import random, math, inkex, simplestyle, cubicsuperpath
class RadiusRandomize(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
self.OptionParser.add_option("-w", "--s_width",
action="store", type="float",
dest="s_width", default=1.0,
help="atrke width")
self.OptionParser.add_option("--title")
def effect(self):
path_strings = []
net_strings= ["M"]
my_path = inkex.etree.Element(inkex.addNS('path','svg'))
s = {'stroke-width': self.options.s_width, 'stroke': '#000000', 'fill': 'none' }
my_path.set('style', simplestyle.formatStyle(s))
for id, node in self.selected.iteritems():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = cubicsuperpath.parsePath(d)
for subpath in p:
for i, csp in enumerate(subpath):
path_strings.append("%f,%f" % ( csp[1][0], csp[1][1]))
node.set('d',cubicsuperpath.formatPath(p))
while len(path_strings)>0 :
net_strings.append(path_strings.pop(0))
if len(path_strings)>0 :
net_strings.append(path_strings.pop())
my_path.set('d', " ".join(net_strings))
self.current_layer.append( my_path )
e = RadiusRandomize()
e.affect()