From dc2dc15aee96015704aa97ef85a169807528ceee Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Thu, 21 Oct 2021 16:18:36 +0200 Subject: [PATCH] add option to affine spirals --- .../affine_spirals/affine_spirals.inx | 1 + .../affine_spirals/affine_spirals.py | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/extensions/fablabchemnitz/affine_spirals/affine_spirals.inx b/extensions/fablabchemnitz/affine_spirals/affine_spirals.inx index 5b92ba53..bbadf929 100644 --- a/extensions/fablabchemnitz/affine_spirals/affine_spirals.inx +++ b/extensions/fablabchemnitz/affine_spirals/affine_spirals.inx @@ -7,6 +7,7 @@ 3 2 0.8 + true diff --git a/extensions/fablabchemnitz/affine_spirals/affine_spirals.py b/extensions/fablabchemnitz/affine_spirals/affine_spirals.py index e7fcd7ed..710b87ad 100644 --- a/extensions/fablabchemnitz/affine_spirals/affine_spirals.py +++ b/extensions/fablabchemnitz/affine_spirals/affine_spirals.py @@ -15,19 +15,22 @@ def ff(v, ww=.25, ds=.4): r,u = exp(-ds*x), cos(pi*ww*y) + 1J*sin(pi*ww*y) return r*u -def mk_plugs(pts): +def mk_plugs(pts, noses): #returns a list of complex representing a plug type segment - segs = [fit_plug(end_pts) for end_pts in zip(pts,pts[1:]) ] + segs = [fit_plug(end_pts, noses) for end_pts in zip(pts,pts[1:]) ] tmp = [] for seg in segs: tmp.extend(seg) return tmp -def fit_plug(ss): +def fit_plug(ss, noses): a,b = ss rot = complex(b-a) pts = [0,.45,.4 + .15*1J, .6 + .15*1J, .55, 1] - return [rot*z + a for z in pts] + if noses is True: + return [rot*z + a for z in pts] + else: + return ss def pts2curve(cplxs): '''makes a polyline path element from a list of complex @@ -46,7 +49,8 @@ class AffineSpirals(inkex.EffectExtension): pars.add_argument("--num_lines", type=int, default=3) pars.add_argument("--num_petals", type=int, default=3) pars.add_argument("--shrink_ratio", type=float, default=3) - pars.add_argument("--active-tab", default='title') + pars.add_argument("--active-tab") + pars.add_argument("--noses", type=inkex.Boolean, default=True) def calc_unit_factor(self): unit_factor = self.svg.unittouu(str(1.0) + self.options.units) @@ -82,9 +86,9 @@ class AffineSpirals(inkex.EffectExtension): payload = [] for y in range(-NP,NP): mpts = [ff(z,ww=1./NP, ds=SF) for z in line(npts=NN, y0=y)] - payload.append(mk_plugs(mpts)) + payload.append(mk_plugs(mpts, self.options.noses)) mpts = [ff(z,ww=1./NP, ds=SF) for z in line(npts=NN, y0=y,sgn=-1 )] - payload.append(mk_plugs(mpts)) + payload.append(mk_plugs(mpts, self.options.noses)) payload = [pts2curve(cc) for cc in payload] payload = ' '.join(payload)