diff --git a/extensions/desktop.ini b/extensions/desktop.ini new file mode 100644 index 0000000..98957c5 --- /dev/null +++ b/extensions/desktop.ini @@ -0,0 +1,5 @@ +[LocalizedFileNames] +fablabchemnitz_scatter.inx=@fablabchemnitz_scatter.inx,0 +fablabchemnitz_scatter.py=@fablabchemnitz_scatter.py,0 +fablabchemnitz_netting.inx=@fablabchemnitz_netting.inx,0 +fablabchemnitz_netting.py=@fablabchemnitz_netting.py,0 diff --git a/extensions/fablabchemnitz_boundingbox.py b/extensions/fablabchemnitz_boundingbox.py deleted file mode 100644 index 80bddc3..0000000 --- a/extensions/fablabchemnitz_boundingbox.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python2 - -import sys -sys.path.append('/usr/share/inkscape/extensions') - -from collections import defaultdict - -from inkex import Effect as InkscapeEffect -from inkex import etree, addNS - -from simpletransform import computeBBox, applyTransformToNode -from simplestyle import formatStyle -from simplepath import parsePath, translatePath, formatPath - -class DrawBBoxes(InkscapeEffect): - def __init__(self): - InkscapeEffect.__init__(self) - self.filename = sys.argv[-1] - - def effect(self): - if len(self.selected) > 0: - bboxes = self.calculate_bboxes(self.selected) - for id, node, bbox in bboxes: - self.draw_bbox(bbox) - - def calculate_bboxes(self, nodes): - bboxes = [(id, node, computeBBox([node])) - for id, node in nodes.items()] - - return bboxes - - def draw_bbox(self, bbox): - (x1, x2, y1, y2) = bbox - width = x2 - x1 - height = y2 - y1 - self.draw_rect(x1, y1, width, height) - - #SVG element generation routine - def draw_rect(self, x, y, width, height): - layer = self.current_layer - - style = { 'stroke' : '#ff0000', - 'stroke-width' : '1', - 'fill' : 'none', - } - - attribs = { - 'style' : formatStyle(style), - 'x' : str(x), - 'y' : str(y), - 'width' : str(width), - 'height' : str(height), - } - - rect = etree.SubElement(layer, addNS('rect','svg'), attribs ) - -effect = DrawBBoxes() -effect.affect() diff --git a/extensions/fablabchemnitz_boundingbox.inx b/extensions/fablabchemnitz_netting.inx similarity index 60% rename from extensions/fablabchemnitz_boundingbox.inx rename to extensions/fablabchemnitz_netting.inx index d0f821a..15c4f47 100644 --- a/extensions/fablabchemnitz_boundingbox.inx +++ b/extensions/fablabchemnitz_netting.inx @@ -1,12 +1,13 @@ - <_name>Bounding Box - fablabchemnitz.de.boundingbox + <_name>Netting + fablabchemnitz.de.netting + fablabchemnitz_netting.py inkex.py - fablabchemnitz_boundingbox.py - Draws bounding boxes around selected objects, useful for debugging. Author: Pawel Mosakowski + <_param name="title" type="description">This effect net in the a path alternately. + 1.0 - all + path @@ -14,6 +15,6 @@ \ No newline at end of file diff --git a/extensions/fablabchemnitz_netting.py b/extensions/fablabchemnitz_netting.py new file mode 100644 index 0000000..9198d79 --- /dev/null +++ b/extensions/fablabchemnitz_netting.py @@ -0,0 +1,63 @@ +#!/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() + diff --git a/extensions/fablabchemnitz_ofsplot.inx b/extensions/fablabchemnitz_ofsplot.inx deleted file mode 100644 index a88d261..0000000 --- a/extensions/fablabchemnitz_ofsplot.inx +++ /dev/null @@ -1,23 +0,0 @@ - - - <_name>Ofsplot (Offset Paths) - fablabchemnitz.de.ofsplot - fablabchemnitz_ofsplot.py - 10 - 0.8 - 0.8 - 0 - 0.8 - <_param name="settingsHelp" type="description">Python library pyclipper needs to be installed. Use Flatten Bezier plugin in advance of this plugin. - - all - - - - - - - - \ No newline at end of file diff --git a/extensions/fablabchemnitz_ofsplot.py b/extensions/fablabchemnitz_ofsplot.py deleted file mode 100644 index 47d5317..0000000 --- a/extensions/fablabchemnitz_ofsplot.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function - -import inkex -import cubicsuperpath, simplestyle, copy, math, re, bezmisc, simplepath -import pyclipper -import sys - -def eprint(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) - - - -class ofsplot(inkex.Effect): - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("--count", - action="store", type="int", - dest="count", default=10, - help="Number of offset operations") - self.OptionParser.add_option("--ofs", - action="store", type="float", - dest="offset", default=2, - help="Offset amount") - self.OptionParser.add_option("--init_ofs", - action="store", type="float", - dest="init_offset", default=2, - help="Initial Offset Amount") - self.OptionParser.add_option("--copy_org", - action="store", type="inkbool", - dest="copy_org", default=True, - help="copy original path") - self.OptionParser.add_option("--ofs_incr", - action="store", type="float", - dest="offset_increase", default=2, - help="Offset increase between iterations") - - - - - def effect(self): - - for id, node in self.selected.iteritems(): - if node.tag == inkex.addNS('path','svg'): - p = cubicsuperpath.parsePath(node.get('d')) - - scale_factor=5.0 - - - pco = pyclipper.PyclipperOffset() - - new = [] - - - # load in initial paths - for sub in p: - sub_simple = [] - h1_simple = [] - h2_simple = [] - for item in sub: - itemx = [float(z)*scale_factor for z in item[1]] - sub_simple.append(itemx) - #eprint(itemx) - #h1_simple.append(item[0]-item[1]) # handle 1 offset - #h2_simple.append(item[2]-item[1]) # handle 2 offset - - pco.AddPath(sub_simple, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON) - - - - # calculate offset paths for different offset amounts - offset_list = [] - offset_list.append(self.options.init_offset) - for i in range(0,self.options.count+1): - ofs_inc = +math.pow(float(i)*self.options.offset_increase,2) - if self.options.offset_increase <0: - ofs_inc = -ofs_inc - offset_list.append(offset_list[0]+float(i)*self.options.offset+ofs_inc) - - - solutions = [] - for offset in offset_list: - solution = pco.Execute(offset*scale_factor) - solutions.append(solution) - if len(solution)<=0: - continue # no more loops to go, will provide no results. - - - # re-arrange solutions to fit expected format & add to array - for solution in solutions: - for sol in solution: - solx = [[float(s[0])/scale_factor, float(s[1])/scale_factor] for s in sol] - sol_p = [[a,a,a] for a in solx] - sol_p.append(sol_p[0][:]) - new.append(sol_p) - - - - - # add old, just to keep (make optional!) - if self.options.copy_org: - for sub in p: - new.append(sub) - - node.set('d',cubicsuperpath.formatPath(new)) - - -if __name__ == '__main__': - e = ofsplot() - e.affect() - diff --git a/extensions/fablabchemnitz_scatter.inx b/extensions/fablabchemnitz_scatter.inx new file mode 100644 index 0000000..c74f8e3 --- /dev/null +++ b/extensions/fablabchemnitz_scatter.inx @@ -0,0 +1,24 @@ + + + <_name>Scatter 2 + fablabchemnitz.de.scatter2 + pathmodifier.py + fablabchemnitz_scatter.py + inkex.py + This effect scatters pattern objects randomly around segment points of arbitrary "skeleton" paths. The pattern is the top most object in the selection. Random_off:density=1,offset=0 + true + 6 + 3 + 20.0 + 20.0 + + + + + + + + + \ No newline at end of file diff --git a/extensions/fablabchemnitz_scatter.py b/extensions/fablabchemnitz_scatter.py new file mode 100644 index 0000000..c87ab6c --- /dev/null +++ b/extensions/fablabchemnitz_scatter.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python +''' +scatter.py +Sunabe kazumichi 2009/9/29 +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 + + +attention:when rotation degree become large, patterns are deformed largely. +therefore,restricted the rotation in range -30