add some modifier parameter

This commit is contained in:
2025-12-17 12:31:39 +01:00
parent 6a8793e808
commit 0494752fe6
2 changed files with 10 additions and 6 deletions
@@ -15,10 +15,11 @@
</param>
<param name="length" type="float" min="0" max="1000000" gui-text="Length (mm)">0</param>
<param name="turns" type="int" min="1" max="1000000" gui-text="Turns" gui-description="Works only if you set 'length (mm)' to 0.0">5</param>
<param name="modifier" type="int" min="0" max="1000000" gui-text="Modifier" gui-description="Play around to make artworks">0</param>
</page>
<page name="tab_about" gui-text="About">
<label appearance="header">Archimedes Spiral</label>
<label>2020 - 2023 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<label>2020 - 2025 / written by Mario Voigt (Stadtfabrikanten e.V. / FabLab Chemnitz)</label>
<spacer/>
<label appearance="header">Online Documentation</label>
<label appearance="url">https://y.stadtfabrikanten.org/archimedesspiral</label>
@@ -28,12 +28,13 @@ class Archimedes(inkex.EffectExtension):
pars.add_argument('--trl', default = '1')
pars.add_argument('--turns', type = float, default = '5')
pars.add_argument('--length', type = float, default = '500')
pars.add_argument('--modifier', type = float, default = '0')
def effect(self):
#th = pi / 1
th = self.options.th / 360 * pi * 2
a = self.options.a
r = self.options.r
modifier = self.options.modifier
length = self.options.length
if length > 0:
@@ -48,18 +49,20 @@ class Archimedes(inkex.EffectExtension):
layer = etree.SubElement(self.document.getroot(),'g')
path = etree.Element(inkex.addNS('path','svg'))
path.set('d', self.built(r, step, a, turns, th))
path.set('d', self.built(r, step, a, turns, th, modifier))
path.set('style',"fill:none;stroke:#000000;stroke-width:1px;stroke-opacity:1")
layer.append(path)
def built(self, r0, st, a, k, th):
def built(self, r0, st, a, k, th, modifier):
step = 2 * pi / st
s = "M " + str(r0 * cos(th)) + ", " + str(-r0 * sin(th))
for i in range(0, int(k * (abs(st)))):
prin = th + i * step
meta = th + (i + 1) * step
rp = r0 + abs(a * prin)# instead we put the absolute value the spiral will drift inwards
rm = r0 + abs(a * meta)# at the absolute price closes outwards
meta = meta + i * modifier
prin = prin + i * modifier
rp = r0 + abs(a * prin) # instead we put the absolute value the spiral will drift inwards
rm = r0 + abs(a * meta) # at the absolute price closes outwards
s += "a " + str(rm) + "," + str(rm) + " 0 0," + self.options.trl + " " + str(-rp * cos(prin) + rm * cos(meta)) + "," + str(rp * sin(prin) -rm * sin(meta))
return s