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

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to