In article 
<769ba7780906240342s4939ac2foe7bfd783ad2e8...@mail.gmail.com>,
 Zhichu Chen <zhichu.c...@gmail.com> wrote:
 
> Well, my example is too simple. Actually, I was trying to draw a
> treble clef

If your goal is to draw a path with pens of varying width (kind of 
calligraphic strokes),'penpos' and 'penstroke' may be your friends 
(defined in plain.mp). This is what I've come out with by about 15 
minutes of trial and error (disclaimer: this is my first attempt at 
using these macros beyond trying to draw a sans-serif 'l' - I'm not a 
designer at all):

   fill unitsquare scaled 12cm shifted (-6cm,-6cm) withcolor .625red;
   b = 2pt; % Default pen width
   w = 30mm; % Width of treble clef
   h = 100mm; % Height of treble clef
   % Specify breadth and angle of pen at keypoints:
   penpos 1 (0.5b, 30);
   penpos 1.5 (b, 15);
   penpos 2 (3b, 0);
   penpos 3 (5b, -90);
   penpos 4 (3b, -180);
   penpos 5 (b, 90);
   penpos 6 (5b,0);
   penpos 6.5 (4b, -30);
   penpos 7 (.5b, 0);
   penpos 8 (5b, 90);
   penpos 9 (3b, -180);
   penpos 10 (b, -180);
   % Fix x coords of keypoints
   x1=0;
   x1.5=1/2[x1,x2];
   x5=x1=x3=x8;
   x10=1/2[x9,x1];
   x7=1/2[x3,x4];
   x4-x6=w;
   x1=1/2[x2,x4];
   x3-x2=x2-x6;
   x9=1/2[x1,x2];
   x6.5=1/2[x5,x6];
   % Fix y coords of keypoints
   y1=0;
   y1.5=y1;
   y6=y2=y4=1/2[y3,y1];
   y3-y1=y1-y5=1/10h;
   y5-y10=2(y3-y1);
   y8-y7=y3-y1;
   y9=y7;
   y8-y3=y3-y10;
   y6.5=1/2[y6,y7];
   
   drawoptions (withcolor background);
   % Draw (an incomplete and ugly) treble clef
   penstroke z1e .. z1.5e .. z2e .. z3e .. z4e .. z5e .. z6e .. z6.5e .. 
z7e .. z8e .. z9e .. z10e;
   drawoptions(withcolor black);
   labels.lft(1,1.5,2,3,4,5,6,6.5,7,8,9,10);

You must take special care never to cross the left and right edges of 
the pen. See The METAFONTbook for details and examples.

Regards,
Nicola

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to