ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Nicola <nvitacolonna@gmail.com>
To: ntg-context@ntg.nl
Subject: Re: How to "unfill" a picture?
Date: Wed, 24 Jun 2009 16:12:44 +0200	[thread overview]
Message-ID: <nvitacolonna-F332F1.16124324062009@news.gmane.org> (raw)
In-Reply-To: <769ba7780906240342s4939ac2foe7bfd783ad2e82ee@mail.gmail.com>

In article 
<769ba7780906240342s4939ac2foe7bfd783ad2e82ee@mail.gmail.com>,
 Zhichu Chen <zhichu.chen@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
___________________________________________________________________________________


  parent reply	other threads:[~2009-06-24 14:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-24  3:13 Zhichu Chen
2009-06-24  6:55 ` Zhichu Chen
2009-06-24  7:32   ` Taco Hoekwater
2009-06-24  7:48     ` Zhichu Chen
2009-06-24  9:02       ` Taco Hoekwater
2009-06-24  8:21 ` Wolfgang Schuster
2009-06-24 10:42   ` Zhichu Chen
2009-06-24 10:59     ` Zhichu Chen
2009-06-24 11:29       ` Hans Hagen
2009-06-24 11:42         ` Zhichu Chen
2009-06-24 14:12     ` Nicola [this message]
2009-06-24 14:45       ` Zhichu Chen
2009-06-25  5:15         ` Lutz Haseloff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=nvitacolonna-F332F1.16124324062009@news.gmane.org \
    --to=nvitacolonna@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).