Initial commit. First part of extensions. More are coming back again

soon.
This commit is contained in:
2022-09-01 10:55:46 +02:00
commit abe8989812
274 changed files with 37671 additions and 0 deletions

View File

@ -0,0 +1,21 @@
[
{
"name": "Slider Electrodes",
"id": "fablabchemnitz.de.slider_electrodes",
"path": "slider_electrodes",
"dependent_extensions": null,
"original_name": "Slider Electrodes",
"original_id": "org.inkscape.render.sliderelectrodes",
"license": "MIT License",
"license_url": "https://github.com/henningpohl/Inkscape-Slider-Electrode-Generator/blob/master/LICENSE",
"comment": "ported to Inkscape v1 by Mario Voigt",
"source_url": "https://gitea.fablabchemnitz.de/FabLab_Chemnitz/mightyscape-1.2/src/branch/master/extensions/fablabchemnitz/slider_electrodes",
"fork_url": "https://github.com/henningpohl/Inkscape-Slider-Electrode-Generator",
"documentation_url": "https://stadtfabrikanten.org/display/IFM/Slider+Electrodes",
"inkscape_gallery_url": null,
"main_authors": [
"github.com/henningpohl",
"github.com/eridur-de"
]
}
]

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Slider Electrodes</name>
<id>fablabchemnitz.de.slider_electrodes</id>
<param name="count" type="int" gui-text="Number of electrodes:" min="1" max="50">5</param>
<param name="spikes" type="int" gui-text="Number of spikes:" min="1" max="10">5</param>
<effect>
<object-type>all</object-type>
<effects-menu>
<submenu name="FabLab Chemnitz Shape Generators">
<submenu name="Streaks And Blobs" />
</submenu>
</effects-menu>
</effect>
<script>
<command location="inx" interpreter="python">slider_electrodes.py</command>
</script>
</inkscape-extension>

View File

@ -0,0 +1,56 @@
#!/usr/bin/env python3
from io import StringIO
import inkex
from lxml import etree
class SliderElectrodes(inkex.EffectExtension):
def add_arguments(self, pars):
pars.add_argument("-c", "--count", type=int, default=5, help="Number of electrodes")
pars.add_argument("-s", "--spikes", type=int, default=5, help="Number of spikes")
def genPathString(self, bounds, spikeWidth, first=False, last=False):
s = StringIO()
cx = bounds[0]
cy = bounds[1]
stepx = spikeWidth
stepy = (bounds[3] - bounds[1]) / (2.0 * self.options.spikes)
s.write(" M %f, %f " % (bounds[0], bounds[1]))
if first:
s.write(" L %f, %f " % (bounds[0], bounds[3]))
else:
for i in range(self.options.spikes):
s.write(" L %f, %f " % (bounds[0] + stepx, bounds[1] + (2 * i + 1) * stepy))
s.write(" L %f, %f " % (bounds[0], bounds[1] + (2 * i + 2) * stepy))
if last:
s.write(" L %f, %f " % (bounds[2], bounds[3]))
s.write(" L %f, %f " % (bounds[2], bounds[1]))
else:
s.write(" L %f, %f " % (bounds[2] - stepx, bounds[3]))
for i in range(self.options.spikes):
s.write(" L %f, %f " % (bounds[2], bounds[3] - (2 * i + 1) * stepy))
s.write(" L %f, %f " % (bounds[2] - stepx, bounds[3] - (2 * i + 2) * stepy))
s.write(" Z ")
return s.getvalue()
def effect(self):
svg = self.document.getroot()
width = self.svg.unittouu(self.document.getroot().get('width'))
height = self.svg.unittouu(self.document.getroot().get('height'))
group = etree.SubElement(self.svg.get_current_layer(), 'g', {inkex.addNS('label', 'inkscape') : 'Slider electrodes'})
eWidth = width / self.options.count
spikeWidth = 0.6 * eWidth
for eid in range(self.options.count):
if eid == 0:
path = self.genPathString((eid * eWidth, 0, (eid + 1) * eWidth + 0.4 * spikeWidth, height), spikeWidth, first=True)
elif eid == self.options.count - 1:
path = self.genPathString((eid * eWidth - 0.4 * spikeWidth, 0, (eid + 1) * eWidth, height), spikeWidth, last=True)
else:
path = self.genPathString((eid * eWidth - 0.4 * spikeWidth, 0, (eid + 1) * eWidth + 0.4 * spikeWidth, height), spikeWidth)
e = etree.SubElement(group, inkex.addNS('path', 'svg'), {'style':str(inkex.Style({'stroke':'none','fill' :'#000000'})),'d' : path})
if __name__ == '__main__':
effect = SliderElectrodes().run()