ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Cc: Mailing List <ntg-context@ntg.nl>
Subject: Re: mpost: cutbefore/cutafter
Date: Sat, 07 Oct 2000 23:26:27 +0200	[thread overview]
Message-ID: <3.0.6.32.20001007232627.008cf800@pop.wxs.nl> (raw)
In-Reply-To: <20001006121204.A10194@cs.ucc.ie>

If members of this list don't want to be overloaded with metapost, we may
consider a dedicated metafun list.  

At 12:12 PM 10/6/00 +0100, Marc van Dongen wrote:
>Dear metapost gurus,
>
>There is something I don't understand about
>cutbefore and cutafter. Maybe what I need is
>in the metafont book which I don't have yet.
>
>Anyway, here it goes.
>
>Is there any way to tell mpost to cut a curve
>exactly at the bpath of a boxed thingy? At the
>moment I am facing the problem that for example
>a cutafter of an arc goes slightly beyond (what
>seems to be) the inner boundary of the bpath of
>a circle.

This has to do with line characteristics. The point itself has infinity
small but you draw it with a certain pen. Using another linecap already
helps. 

>I have attached a picture which demonstrates the
>effect. In this picture the phenomenon manifests
>itself with the first three circles at the bottom.
>The arcs were drawn with a command that drew them
>from the centres of the circles cutbefore and
>cutafter the bpaths of the circles.
>
>Ideally I would like to have control where to cut
>the arcs. For example, it would be very nice if
>it were possible to cut exactly at the outside of
>where a circle is draw or to cut it exactly at
>the inside of where a circle is drawn. Is there
>any way to do this?

You can forst raw the lines and then the circles. You can cut the linewidth
from the connecting path using the metafun point length on path operation. 

\setupcolors[state=start]

\starttext

\startMPpage

path p, q, r ; pair pr, qr ;

p := fullcircle scaled 4cm ;
q := fullcircle scaled 3cm shifted (5cm,6cm) ;
r := center p -- center q ;

pr := p intersectionpoint r ;
qr := q intersectionpoint r ;

r := r cutbefore pr ; r := r cutafter qr ;
r := r cutbefore (point 2.5pt on r) ;
r := reverse r ;
r := r cutbefore (point 2.5pt on r) ;

draw r withpen pencircle scaled 10pt;
draw p withpen pencircle scaled 5pt withcolor red ;
draw q withpen pencircle scaled 5pt withcolor green ;

\stopMPpage

\stoptext

I played a bit with clipping but that's too tricky and fuzzy (you can do
nice tricks that way). I will think about adding something of 'connecting'
things in the metafun manual. [some of this is taking place in the flow
chart module, btw] I've extended 'on' to accept negative values: 

primarydef len on pat =
  (arctime if len>0 : len else : (arclength(pat)+len) fi of pat) of pat
enddef ;

so then you get

r := r cutbefore pr ; r := r cutafter qr ;
r := r cutbefore (point  2.5pt on r) ;
r := r cutafter  (point -2.5pt on r) ;

I will not bore you with the macro cutends that i added to metafun a minute
ago

r cutends 2.5pt 

Hans

Hans  
-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


  reply	other threads:[~2000-10-07 21:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-06 11:12 Marc van Dongen
2000-10-07 21:26 ` Hans Hagen [this message]
2000-10-09 18:51   ` Berend de Boer
2000-10-09 19:34     ` metafun talk in ntg-context list (was Re: mpost: cutbefore/cutafter) Ed L Cashin
2000-10-09 19:55       ` metafun talk in ntg-context list (was Re: mpost:cutbefore/cutafter) Hans Fredrik Nordhaug
2000-10-09 20:07         ` metafun talk in ntg-context list (was Re: mpost: cutbefore/cutafter) Ed L Cashin

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=3.0.6.32.20001007232627.008cf800@pop.wxs.nl \
    --to=pragma@wxs.nl \
    --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).