Re: [NTG-context] Problem in using vlingrid() and hlingrid() macros (Metafun)

2015-03-15 Thread Fabrice

Hi,
To solve my problem, I finally used a loop to draw a grid.
Fabrice

\starttext
\start
\switchtobodyfont[small]
\startMPcode
 path p ;
 u := 2cm ; v:= 1cm ;
 p := (-u,-5v)--(3u,-5v)--(3u,4v)--(-u,4v)--cycle ;
 drawoptions(withpen pencircle scaled 0.5pt withcolor 
\MPcolor{mycolor});

 for i=-u step u until 3u :
 draw (i,-5v)--(i,4v) ;
 endfor ;
 for i=-5v step v until 4v :
 draw (-u,i)--(3u,i) ;
 endfor ;
 drawoptions(withpen pencircle scaled 1pt) ;
 drawarrow (-u,0)--(3u,0) ;
 drawarrow (0,-5v)--(0,4v) ;
 draw (u,-0.05v)--(u,0.05v) ;
 draw (-0.025u,v)--(0.025u,v) ;
 draw curvedfunction (x, 3*x*x-5*x+1, -1, 3, 0.01) xyscaled 
(u,v) withcolor red ;
 draw curvedfunction (x, -5*x+1, -1, 3, 0.01) xyscaled (u,v) 
withcolor blue ;
 draw curvedfunction (x, 7*x-11, -1, 3, 0.01) xyscaled (u,v) 
withcolor green ;

 label.bot(btex $x$ etex,(2.97u,-0.1v)) ;
 label.rt(btex $y$ etex,(0.01u,3.9v)) ;
 label.llft(0,(0,0)) ;
 label.urt(A,(0,v)) ;
 dotlabel(,(u,-4v)) ;
 label.rt(C,(1.02u,-4v)) ;
 dotlabel.lrt(B,(2u,3v)) ;
 label.bot(1,(u,0)) ;
 label.lft(1,(0,v)) ;
 clip currentpicture to p ;
\stopMPcode
\stop
\stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

[NTG-context] Problem in using vlingrid() and hlingrid() macros (Metafun)

2015-03-14 Thread Fabrice Couvreur
Hi,
I encounter some problems in the use of vlingrid() and hlingrid() macros. In
the code below, we see that the grid is not correct.
Does the code can be improved ?
thank you,
Fabrice

\starttext
\startMPcode
 path p ;
 u := 2cm ; v:= 1cm ;
 p := (-u,-5v)--(3u,-5v)--(3u,4v)--(-u,4v)--cycle ;
 drawoptions(withpen pencircle scaled 0.5pt withcolor
\MPcolor{mycolor});
 draw vlingrid(-u,3u,u,4u,9v) shifted (0,-5v) ;
 draw hlingrid(-5v,4v,v,9v,4u)  shifted (-u,0)  ;
 drawoptions(withpen pencircle scaled 1pt) ;
 drawarrow (-u,0)--(3u,0) ;
 drawarrow (0,-5v)--(0,4v) ;
   draw curvedfunction (x, 3*x*x-5*x+1, -1, 3, 0.01) xyscaled (u,v)
withcolor red ;
 draw curvedfunction (x, -5*x+1, -1, 3, 0.01) xyscaled (u,v)
withcolor blue ;
 draw curvedfunction (x, 7*x-11, -1, 3, 0.01) xyscaled (u,v)
withcolor green ;
 label.bot(btex $x$ etex,(2.97u,-0.1v)) ;
 label.rt(btex $y$ etex,(0.01u,3.9v)) ;
 label.llft(0,(0,0)) ;
 dotlabel.urt(A,(0,v)) ;
 dotlabel(,(u,-4v)) ;
 label.rt(C,(1.02u,-4v)) ;
 dotlabel.lrt(B,(2u,3v)) ;
 label.bot(1,(u,0)) ;
 label.lft(1,(0,v)) ;
 clip currentpicture to p ;
\stopMPcode
\stoptext
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___