+% 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)
+%
+% Note that `currentpen' must be set correctly -- only circular pens
+% are supported properly.
+
+def flare_path (expr pos, alpha, beta, line, flare, direction) =
+begingroup;
+ save thick;
+
+ thick = pen_top + pen_bot;
+
+ clearxy;
+
+ penpos1' (line - thick, 180 + beta + alpha);
+ top z1'r = pos;
+
+ penpos2' (flare - thick, 180 + beta + alpha);
+ z2' = z3';
+
+ penpos3' (flare - thick, 0 + alpha);
+ rt x3'l = hround (x1'r
+ + (1/2 + 0.43) * flare * xpart dir (alpha + beta));
+ bot y2'l = vround (y1'r
+ + (1 + 0.43) * flare * ypart dir (alpha + beta));
+
+ rt x4' = x2'r - line * xpart dir (alpha);
+ y4' = y2'r - line * ypart dir (alpha);
+
+ penlabels (1', 2', 3', 4');
+
+ save t, p;
+ t = 0.833;
+ path p;
+
+ p := z1'r{dir (alpha)}
+ .. z3'r{dir (180 + alpha - beta)}
+ .. z2'l{dir (alpha + 180)}
+ .. z3'l{dir (180 + alpha + beta)}
+ ..tension t.. z4'{dir (180 + alpha + beta)}
+ .. z1'l{dir (alpha + 180)};
+
+ if direction <> 1:
+ p := reverse p;
+ fi;
+
+p
+endgroup
+enddef;
+
+
+def brush (expr a, w, b, v) =
+begingroup;
+ draw_brush (a, w, b, v);
+ penlabels (3, 4, 5, 6);
+endgroup;
+enddef;
+
+