[NTG-context] using symbols in MetaFun

Hans Hagen pragma at wxs.nl
Mon Feb 13 11:44:58 CET 2006


Mojca Miklavec wrote:
> Hello,
>
> I have a "conversion" defined in the following way:
>
> \usesymbols[jmn]
> \defineconversion
>    [gnuplot]
>    [$\bullet$,
>     $\circ$,
>     $\star$,
>     x,
>     {\symbol[navigation 1][NextJump]}]
>
> I would like to use these symbols in a macro
>     draw_symbol(x,y,number)
> so that
>     draw_symbol(0,0,3)
> would draw a star in the origin.
>
> The problem is that I don't know:
> - how to use symbol sets inside MetaFun (verbatimtex \usesymbols[jmn]
> etex doesn't work here)
> - how to enable
>     label(btex \convertnumber{gnuplot}{5} etex, (x,y))
>   to work properly in metafun (no luck with verbatimtex ... etex again)
>
> Any hints would be appreciated.
>   
==== test.tex ==== 

\starttext

\startMPenvironment [global]

    \readfile{test-gnuplot}{}{}

\stopMPenvironment

\setupcolors[state=start]

\startMPcode
def the_symbol(expr n) =
    textext("\GnuPlotSymbol{" & decimal n & "}")
enddef ;
def draw_symbol(expr x, y, n) =
    draw the_symbol(n) shifted (x,y)
enddef ;

for i=1 upto 10 :
    draw_symbol(i*10,i*10,i) withcolor red ;
endfor ;
\stopMPcode

\stoptext


=== test-gnuplot.tex ==== 

\defineconversion
  [gnuplot]
  [$\bullet$,
   $\circ$,
   $\star$,
   x,
  {\symbol[navigation 1][NextJump]}]

\unexpanded\def\GnuPlotSymbol#1%
  {\convertnumber{gnuplot}{#1}}


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



More information about the ntg-context mailing list