[metapost] Bug with the binary operator `point ... on ...` from Metafun

Hans Hagen pragma at wxs.nl
Mon Mar 9 17:17:26 CET 2015


On 3/9/2015 5:01 PM, Franck Pastor wrote:
> I’ve just encountered a very puzzling bug with the binary operator `point <len> of <path>` defined in the Metafun format.
>
> In the Metafun manual (http://www.pragma-ade.com/general/manuals/metafun-p.pdf), p. 61, this binary operator is defined as such:
>
> primarydef len of pat =
>    (arctime len of pat) of pat
> enddef;
>
> So if I write `point 0 on pat`, it should return the starting point of the path <pat>, right? But n. To the contrary, it returns the end point of <pat>! Stranger yet, if I try `point (arctime 0 of pat) of pat`, it returns the starting point, as expected.
>
> This weird behavior is illustrated by the following program, to be run with the Metafun format of course:
>
> beginfig(1);
> path line[]; line1 = origin -- 3cm*right; line2 = line1 yshifted -1cm;
> draw line1; draw line2;
> pickup pencircle scaled 3bp;
> draw point 0 of line1; % draw a dot at the start point, as expected
> draw point 0 on line1; % draws a dot at the end point!!!!!
> draw point (arctime 0 of line2) of line2; % draws a dot at the starting point…
> endfig;
> end.
>
> An idea about what is wrong?
>
> I use MetaPost 1.902 and Metafun version 1.004, from TeX Live 2014.

change > into >= in mp-tool.*

\startMPpage

     primarydef len on pat = % no outer ( ) .. somehow fails
         (arctime if len>=0 : len else : (arclength(pat)+len) fi of pat) 
of pat
     enddef ;

     path line[] ;
     line1 = origin -- 3cm*right ;
     line2 = line1 yshifted -1cm ;
     drawarrow line1 ;
     drawarrow line2 ;
     pickup pencircle scaled 3bp ;
     draw point 0 of line1 ; % draw a dot at the start point, as expected
     draw point 0 on line1 withcolor blue ; % draws a dot at the end 
point!!!!!
     draw point 2cm on line1 withcolor red ; % draws a dot at the end 
point!!!!!
     draw point (arctime 0 of line2) of line2 ; % draws a dot at the 
starting point…

\stopMPpage


> Thanks in advance,
>
> Franck Pastor
>
>
>
> --
> http://tug.org/metapost/
>


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the metapost mailing list