* Drawing oriented paths in MetaFun
@ 2005-11-16 14:48 Giuseppe Bilotta
2005-11-16 15:40 ` Giuseppe Bilotta
2005-11-16 16:06 ` Hans Hagen
0 siblings, 2 replies; 5+ messages in thread
From: Giuseppe Bilotta @ 2005-11-16 14:48 UTC (permalink / raw)
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?
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drawing oriented paths in MetaFun
2005-11-16 14:48 Drawing oriented paths in MetaFun Giuseppe Bilotta
@ 2005-11-16 15:40 ` Giuseppe Bilotta
2005-11-16 15:46 ` Re[2]: " Giuseppe Bilotta
2005-11-16 16:15 ` Hans Hagen
2005-11-16 16:06 ` Hans Hagen
1 sibling, 2 replies; 5+ messages in thread
From: Giuseppe Bilotta @ 2005-11-16 15:40 UTC (permalink / raw)
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 ?
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re[2]: Drawing oriented paths in MetaFun
2005-11-16 15:40 ` Giuseppe Bilotta
@ 2005-11-16 15:46 ` Giuseppe Bilotta
2005-11-16 16:15 ` Hans Hagen
1 sibling, 0 replies; 5+ messages in thread
From: Giuseppe Bilotta @ 2005-11-16 15:46 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drawing oriented paths in MetaFun
2005-11-16 15:40 ` Giuseppe Bilotta
2005-11-16 15:46 ` Re[2]: " Giuseppe Bilotta
@ 2005-11-16 16:15 ` Hans Hagen
1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2005-11-16 16:15 UTC (permalink / raw)
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 ?
>
>
>
add another step (do_do_) , first pick up 'reverse p1' as expression,
save that in a path variable, and then pick up the text
Hans
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Drawing oriented paths in MetaFun
2005-11-16 14:48 Drawing oriented paths in MetaFun Giuseppe Bilotta
2005-11-16 15:40 ` Giuseppe Bilotta
@ 2005-11-16 16:06 ` Hans Hagen
1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2005-11-16 16:06 UTC (permalink / raw)
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?
>
>
>
it's there; watch out, i just added a scaling option
\starttext
\setupcolors[state=start]
\startMPpage
vardef arrowheadonpath (expr p, s) =
save autoarrows ; boolean autoarrows ; autoarrows := true ;
set_ahlength(scaled ahfactor) ; % added
arrowhead p if s<1 : cutafter (point (s*arclength(p)+.5ahlength) on p) fi
enddef ;
path p ; p := (0,0)--(10cm,10cm) ;
draw p withcolor red ;
ahfactor := 5 ; % default is 2.5
fill arrowheadonpath(p,.5) withcolor blue ; % try .25
currentpicture := currentpicture xsized (10cm) ;
\stopMPpage
\stoptext
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-16 16:15 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-16 14:48 Drawing oriented paths in MetaFun Giuseppe Bilotta
2005-11-16 15:40 ` Giuseppe Bilotta
2005-11-16 15:46 ` Re[2]: " Giuseppe Bilotta
2005-11-16 16:15 ` Hans Hagen
2005-11-16 16:06 ` Hans Hagen
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).