% Chapter 9. Functions
%
% 9.3 Drawing functions
\setupcolors [state=start]

\starttext

  % If \startMPpage is used, the generating mps graphic does not have
  % accurate bounding box. Why?

  %\startuseMPgraphic{function demo}
  \startMPpage 
    StartPage ; 
      drawoptions(withpen pencircle scaled .25pt withcolor .5white) ; 

      draw hlingrid (0, 20, .2, 20cm, 10cm) ; 
      draw vloggrid (0, 10, .5, 10cm, 20cm) ; 

      drawoptions(withpen pencircle scaled .50pt) ; 

      draw hlingrid (0, 20, 1, 20cm, 10cm) ; 
      draw vloggrid (0, 10, 1, 10cm, 20cm) ; 

      fmt_pictures := false ;     % use the TeX as formatting engine 
      textextoffset := ExHeight ; % a variable set by ConTeXt 

      draw hlintext.lft(0, 20, 5, 20cm, "@3e") ; 
      draw vlogtext.bot(0, 10, 9, 10cm, "@3e") ; 

      draw 
        function(1,"log(x)","x",1,10,1) xyscaled (10cm,2cm) 
        withpen pencircle scaled 5mm withcolor transparent(1,.5,yellow) ; 
      draw 
        function(2,".5log(x)","x",1,10,1) xyscaled (10cm,2cm) 
        withpen pencircle scaled 5mm withcolor transparent(1,.5,blue) ; 
    StopPage ; 
  \stopMPpage 
  %\stopuseMPgraphic

  \useMPgraphic{function demo}

\stoptext
