refactored file structures to match extension ids, file names and class names

This commit is contained in:
2021-06-02 23:30:37 +02:00
parent d95e0ce262
commit e1daf4c934
2405 changed files with 1754 additions and 1775 deletions

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Zigzag Nodes</name>
<id>fablabchemnitz.de.zigzag_nodes</id>
<label>This effect shifts the nodes of the selected path alternately.</label>
<param name="radius" type="float" min="0.0" max="1000.0" gui-text="Maximum displacement, px">3.0</param>
<effect>
<object-type>path</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz">
<submenu name="Shape/Pattern from existing Path(s)"/>
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">zigzag_nodes.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,85 @@
#!/usr/bin/env python3
'''
zigzag.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
this program shifts the nodes zigzags.
'''
import random
import math
import inkex
from inkex import CubicSuperPath
def pointdistance(x1, y1, x2, y2):
dist=math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))
if dist==0:
dx=0
dy=0
else:
dx=(x2 - x1)/dist
dy=(y2 - y1)/dist
return dx,dy
def randomize(x,y, r):
if y == 0:
a = math.pi
elif x == 0 and y != 0:
a = math.pi/2
else:
a = math.atan2(y,x)
x = math.cos(a-math.pi/2)*r
y = math.sin(a-math.pi/2)*r
return [x, y]
class ZigzagNodes(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("--title")
pars.add_argument("--radius", type=float, default=10.0, help="Randomly move control and end points in this radius")
def effect(self):
for id, node in self.svg.selected.items():
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
p = CubicSuperPath(d)
for subpath in p:
for i, csp in enumerate(subpath):
if i % 2 != 0:
dx,dy=pointdistance(csp[0][0],csp[0][1],csp[1][0],csp[1][1])
delta=randomize(dx, dy, self.options.radius)
csp[0][0]+=delta[0]
csp[0][1]+=delta[1]
csp[1][0]+=delta[0]
csp[1][1]+=delta[1]
csp[2][0]+=delta[0]
csp[2][1]+=delta[1]
else:
dx,dy=pointdistance(csp[0][0],csp[0][1],csp[1][0],csp[1][1])
delta=randomize(dx, dy, self.options.radius)
csp[0][0]-=delta[0]
csp[0][1]-=delta[1]
csp[1][0]-=delta[0]
csp[1][1]-=delta[1]
csp[2][0]-=delta[0]
csp[2][1]-=delta[1]
node.set('d',CubicSuperPath(p))
if __name__ == '__main__':
ZigzagNodes().run()