- save za, zb, zc, zd, ze, zf;
- pair za, zb, zc, zd, ze, zf;
- pickup pencircle
- xscaled 2.4 stemthick
- yscaled 0.4 stemthick
- rotated 45;
-
- za = (0.00 staff_space, +1.80 staff_space);
- zb = (0.00 staff_space, -0.15 staff_space);
- zc = (0.25 staff_space, -0.30 staff_space);
- zd = (0.50 staff_space, +0.00 staff_space);
- ze = (0.30 staff_space, +0.30 staff_space);
- zf = (0.00 staff_space, +0.15 staff_space);
- draw za -- zb -- zc .. zd .. ze -- zf;
-
- set_char_box(0.00 staff_space# + 1.0 stemthick#,
- 0.50 staff_space# + 1.0 stemthick#,
- 0.30 staff_space# + 0.5 stemthick#,
- 1.80 staff_space# + 0.5 stemthick#);
-
- fet_endchar;
-
-fet_endgroup ("accidentals")
+ save ellipse, pat, T;
+ path ellipse, pat;
+ transform T;
+
+ T := identity xscaled 2.4 stemthick
+ yscaled 0.4 stemthick
+ rotated 45;
+ pickup pencircle transformed T;
+ ellipse := fullcircle transformed T;
+
+ z1 = (0.00 staff_space, +1.80 staff_space);
+ z2 = (0.00 staff_space, -0.15 staff_space);
+ z3 = (0.25 staff_space, -0.30 staff_space);
+ z4 = (0.50 staff_space, +0.00 staff_space);
+ z5 = (0.30 staff_space, +0.30 staff_space);
+ z6 = (0.00 staff_space, +0.15 staff_space);
+
+ pat := z3
+ .. z4
+ .. z5;
+
+ save t;
+ numeric t[];
+
+ % we have to find the envelope intersections (if any)
+ t1 = find_envelope_cusp (reverse ellipse, pat, 1/256) + 3;
+ if t1 < 3:
+ t1 := 3;
+ fi;
+ t2 = find_envelope_cusp (ellipse, reverse pat, 1/256);
+ if t2 < 0:
+ t2 := 3;
+ else:
+ t2 := length pat - t2 + 3;
+ fi;
+
+ save dirs, s;
+ pair dirs[];
+
+ s := 1/8;
+
+ % we approximate `draw pat'
+ for i = 3 step s until 5:
+ dirs[i] := direction (i - 3) of pat;
+ endfor;
+
+ fill get_subpath (ellipse, up, down, z1)
+ -- get_subpath (ellipse, down, z3 - z2, z2)
+ -- get_subpoint (ellipse, z3 - z2, z3)
+ for i = 3 step s until 5:
+ .. get_subpoint (ellipse, dirs[i],
+ point (i - 3) of pat)
+ endfor
+ .. get_subpoint (ellipse, z6 - z5, z5)
+ -- get_subpoint (ellipse, z6 - z5, z6)
+ -- get_subpoint (ellipse, z5 - z6, z6)
+ -- get_subpoint (ellipse, z5 - z6, z5)
+ -- get_subpoint (ellipse, -dirs[5], z5)
+ for i = (5 - s) step -s until t2:
+ .. get_subpoint (ellipse, -dirs[i],
+ point (i - 3) of pat)
+ endfor
+ .. get_subpoint (ellipse, -direction (t2 - 3) of pat,
+ point (t2 - 3) of pat)
+ -- get_subpoint (ellipse, -direction (t1 - 3) of pat,
+ point (t1 - 3) of pat)
+ for i = (floor ((t1 - 3) / s) * s + 3) step -s until (3 + s):
+ .. get_subpoint (ellipse, -dirs[i],
+ point (i - 3) of pat)
+ endfor
+ .. get_subpoint (ellipse, -dirs[3], z3)
+ -- get_subpoint (ellipse, z2 - z3, z3)
+ -- get_subpoint (ellipse, z2 - z3, z2)
+ -- get_subpoint (ellipse, up, z2)
+ -- cycle;
+
+% draw z1
+% -- z2
+% -- pat
+% -- z6;
+
+ set_char_box (0.00 staff_space# + 1.0 stemthick#,
+ 0.50 staff_space# + 1.0 stemthick#,
+ 0.30 staff_space# + 0.5 stemthick#,
+ 1.80 staff_space# + 0.5 stemthick#);
+
+ labels (1, 2, 3, 4, 5, 6);
+fet_endchar;
+
+
+fet_endgroup ("accidentals");