ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Giuseppe Bilotta <gip.bilotta@iol.it>
Subject: Re[2]: Drawing oriented paths in MetaFun
Date: Wed, 16 Nov 2005 16:46:04 +0100	[thread overview]
Message-ID: <1606851465.20051116164604@iol.it> (raw)
In-Reply-To: <1685015719.20051116164044@iol.it>

Wednesday, November 16, 2005 Giuseppe Bilotta wrote:

> Wednesday, November 16, 2005 Giuseppe Bilotta wrote:

>> Does MetaFun provide some macro to draw oriented paths? I
>> would like it to basically add a small arrow *in the middle*
>> of the path? Such a macro

>> draworiented somepath somespecs ;

>> would have to act like

>> drawarrow firsthalf(somepath) somespecs ;
>> draw secondhalf(somepath) somespecs ;

>> Is it available already, or should I roll my own?


> Hm. I came up with

> def draworiented expr c =
>   path _c_ ; _c_ := c ;
>   do_draworiented
> enddef ;

> def do_draworiented text t =
>   draw _c_ t ;
>   drawarrow subpath(0, length(_c_)/2) of _c_ ;
> enddef;
 
> which works, although I have to do

> draworiented (reverse p1)

> Is there an easy way to have it work with

> draworiented reverse p1 ?


Oh sorry it works ... however, it traces half of the curve
twice. So I came up with the next:

def draworiented expr c =
  path _c_ ; _c_ := c ;
  do_draworiented
enddef ;

def do_draworiented text t =
  drawarrow subpath(0, length(_c_)/2) of _c_ t ;
  draw subpath(length(_c_)/2, length(_c_)) of _c_ t ;
enddef;
 
This still isn't perfect, but it works. It needs a little
tuning so that the arrow is more centered, and of course it
could be improved to put the arrow at any arbitrary point on
the path.

-- 
Giuseppe "Oblomov" Bilotta

  reply	other threads:[~2005-11-16 15:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-16 14:48 Giuseppe Bilotta
2005-11-16 15:40 ` Giuseppe Bilotta
2005-11-16 15:46   ` Giuseppe Bilotta [this message]
2005-11-16 16:15   ` Hans Hagen
2005-11-16 16:06 ` Hans Hagen

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=1606851465.20051116164604@iol.it \
    --to=gip.bilotta@iol.it \
    --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).