+
+
+%
+% make a superellipsoid segment going from FROM to TO, with SUPERNESS.
+% Take superness = sqrt(2)/2 to get a circle segment
+%
+% see Knuth, p. 267 and p.126
+def super_curvelet(expr from, to, superness, dir) =
+ if dir = 1:
+ (superness [xpart to, xpart from], superness [ypart from,ypart to]){to - from}
+ else:
+ (superness [xpart from, xpart to], superness [ypart to,ypart from]){to - from}
+ fi
+enddef;
+
+
+%
+% Bulb with smooth inside curve.
+%
+% alpha = start direction.
+% beta = which side to turn to.
+% flare = diameter of the bulb
+% line = diameter of line attachment
+% direction = is ink on left or right side (1 or -1)
+%
+def flare_path(expr pos,alpha,beta,line,flare, direction) =
+ begingroup;
+ clearxy;
+ penpos1(line,180+beta+alpha);
+ z1r=pos;
+ penpos2(flare,180+beta+alpha);
+ z2=z3;
+ penpos3(flare,0+alpha);
+ z3l=z1r+(1/2+0.43)*flare*dir(alpha+beta) ;
+ save taille;
+ taille = 0.0;
+ z4=z2r- line * dir(alpha);
+ penlabels(1,2,3,4);
+ pickup pencircle;
+ save t; t=0.833;
+ save p;
+ path p;
+ p:=z1r{dir(alpha)}..z3r{dir(180+alpha-beta)}..z2l{dir(alpha+180)}
+ ..z3l{dir(180+alpha+beta)}..tension t
+ ..z4{dir(180+alpha+beta)}..z1l{dir(alpha+180)};
+
+ if direction = 1:
+ p
+ else:
+ reverse p
+ fi
+ endgroup
+ enddef;
+
+
+