some small mods in apollian gasket and affine spirals

This commit is contained in:
Mario Voigt 2021-06-10 00:09:51 +02:00
parent 4072c0d4da
commit 50f891d9ba
4 changed files with 31 additions and 20 deletions

View File

@ -4,9 +4,9 @@
<id>fablabchemnitz.de.affine_spirals</id>
<param name="active-tab" type="notebook">
<page name="title" gui-text="Settings">
<param name="num_lines" type="int" min="1" max="6" gui-text="Depth">3</param>
<param name="num_petals" type="int" min="2" max="8" gui-text="petals">2</param>
<param name="shrink_ratio" type="float" min="0.1" max="0.9" precision="2" gui-text="shrink factor">0.8</param>
<param name="num_lines" type="int" min="1" max="100" gui-text="Depth">3</param>
<param name="num_petals" type="int" min="2" max="100" gui-text="petals">2</param>
<param name="shrink_ratio" type="float" min="0.01" max="0.99" precision="2" gui-text="shrink factor">0.8</param>
</page>
</param>
<effect>

View File

@ -3,18 +3,20 @@
<name>Apollonian Gasket</name>
<id>fablabchemnitz.de.apollonian_gasket</id>
<param name="active_tab" type="notebook">
<page name="title" gui-text="Settings">
<param name="depth" type="int" min="2" max="7" gui-text="Depth">3</param>
<page name="settings" gui-text="Settings">
<param name="depth" type="int" min="2" max="10" gui-text="Depth" gui-description="Warning: high values might calculate really long!">3</param>
<param name="c1" type="float" min="0.1" max="10.0" precision="2" gui-text="c1">2.0</param>
<param name="c2" type="float" min="0.1" max="10.0" precision="2" gui-text="c2">3.0</param>
<param name="c3" type="float" min="0.1" max="10.0" precision="2" gui-text="c3">3.0</param>
<param name="shrink" type="bool" gui-text="shrink circles for cutting">true</param>
<param name="as_paths" type="bool" gui-text="draw svg:path instead svg:circle elements">true</param>
</page>
<page name="Usage1" gui-text="Usage">
<page name="Usage" gui-text="Usage">
<label xml:space="preserve">Make an apollonian gasket:
Depth = depth in search tree
Depth = depth in search tree
c1,c2,c3 = curvatures of first 3 osculating circles</label>
c1,c2,c3 = curvatures of first 3 osculating circles</label>
<label appearance="url">https://en.wikipedia.org/wiki/Apollonian_gasket</label>
</page>
</param>

View File

@ -13,23 +13,29 @@ def cplxs2pts(zs):
return tt
def draw_SVG_circle(parent, r, cx, cy, name):
" structre an SVG circle entity under parent "
" structure an SVG circle entity under parent "
circ_attribs = { 'cx': str(cx), 'cy': str(cy),
'r': str(r),
inkex.addNS('label','inkscape'): name}
circle = etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs )
circle = etree.SubElement(parent, inkex.addNS('circle','svg'), circ_attribs)
def draw_SVG_circleAsPath(parent, r, cx, cy, name):
circ_attribs = {
"d": "M {:0.6f}, {:0.6f} a {:0.6f},{:0.6f} 0 1,0 {:0.6f},0 a {:0.6f},{:0.6f} 0 1,0 {:0.6f},0".format(
cx - r, cy, r, r, 2*r, r, r, -2*r),
inkex.addNS('label','inkscape'): name}
circle = etree.SubElement(parent, inkex.addNS('path','svg'), circ_attribs)
class Gasket(inkex.EffectExtension): # choose a better name
def add_arguments(self, pars):
pars.add_argument("--depth",type=int, default=3, help="command line help")
pars.add_argument("--c1", type=float, default=2.0, help="command line help")
pars.add_argument("--c2", type=float, default=3.0, help="command line help")
pars.add_argument("--c3", type=float, default=3.0, help="command line help")
pars.add_argument("--shrink", type=inkex.Boolean, default=True, help="command line help")
pars.add_argument("--active_tab", default='title', help="Active tab.")
pars.add_argument("--active_tab")
pars.add_argument("--depth",type=int, default=3)
pars.add_argument("--c1", type=float, default=2.0)
pars.add_argument("--c2", type=float, default=3.0)
pars.add_argument("--c3", type=float, default=3.0)
pars.add_argument("--shrink", type=inkex.Boolean, default=True)
pars.add_argument("--as_paths", type=inkex.Boolean, default=True)
def calc_unit_factor(self):
unit_factor = self.svg.unittouu(str(1.0) + self.options.units)
@ -86,7 +92,10 @@ class Gasket(inkex.EffectExtension): # choose a better name
#rescale and add circle to document
cx, cy, r = scale_factor * cx , scale_factor * cy, scale_factor * r
draw_SVG_circle(topgroup, r, cx, cy, 'apo')
if self.options.as_paths is False:
draw_SVG_circle(topgroup, r, cx, cy, 'apollian')
else:
draw_SVG_circleAsPath(topgroup, r, cx, cy, 'apollian')
if __name__ == '__main__':
Gasket().run()

View File

@ -406,7 +406,7 @@ class vpypetools (inkex.EffectExtension):
if self_viewBox is not None:
element.set('transform', 'scale(' + str(scaleX) + ',' + str(scaleY) + ')') #imported groups need to be transformed. Or they have wrong size. Reason: different viewBox sizes/units in namedview definitions
# convert vpype polylines/lines/polygons to regular paths again (strokes to paths)
# convert vpype polylines/lines/polygons to regular paths again (objects to paths)
if self.options.strokes_to_paths is True:
for line in element.iter("{http://www.w3.org/2000/svg}line"):
newLine = PathElement()