ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* using symbols in MetaFun
@ 2006-02-11  4:28 Mojca Miklavec
  2006-02-12 19:03 ` Taco Hoekwater
  2006-02-13 10:44 ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: Mojca Miklavec @ 2006-02-11  4:28 UTC (permalink / raw)


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.

Thanks,
    Mojca

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using symbols in MetaFun
  2006-02-11  4:28 using symbols in MetaFun Mojca Miklavec
@ 2006-02-12 19:03 ` Taco Hoekwater
  2006-02-13 11:22   ` Hans Hagen
  2006-02-13 10:44 ` Hans Hagen
  1 sibling, 1 reply; 5+ messages in thread
From: Taco Hoekwater @ 2006-02-12 19:03 UTC (permalink / raw)


Mojca Miklavec wrote:
> 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.

I am very much a beginner at metafun, so the following is probably
garbage, but to its defence I can say that it actually achieves the
goal :)

There are two files:

% myenv.tex: contains the symbol definition
\usesymbols[jmn]
\defineconversion
    [gnuplot]
    [$\bullet$,
     $\circ$,
     $\star$,
     x,
     {\symbol[navigation 1][NextJump]}]
% end

% sym.tex: the main file
\environment myenv

\startMPinclusions
def draw_symbol(expr X, Y, Number) =
   label(textext(char 92 & "input myenv " &
                 char 92 & "convertnumber{gnuplot}{" &
                            decimal Number & "}"),(X,Y))
enddef
\stopMPinclusions

\starttext
\startuseMPgraphic
draw_symbol(0,0,3);
\stopuseMPgraphic
\useMPgraphic
\stoptext
% end

I could not figure out how to use a 'verbatimtex' preamble either,
so this loads the myenv definition file for each label. Ugly, but
the best I can manage with my current knowledge.

Cheers,
Taco

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using symbols in MetaFun
  2006-02-11  4:28 using symbols in MetaFun Mojca Miklavec
  2006-02-12 19:03 ` Taco Hoekwater
@ 2006-02-13 10:44 ` Hans Hagen
  2006-02-15 15:42   ` Mojca Miklavec
  1 sibling, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2006-02-13 10:44 UTC (permalink / raw)


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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using symbols in MetaFun
  2006-02-12 19:03 ` Taco Hoekwater
@ 2006-02-13 11:22   ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2006-02-13 11:22 UTC (permalink / raw)


Taco Hoekwater wrote:
> I could not figure out how to use a 'verbatimtex' preamble either,
> so this loads the myenv definition file for each label. Ugly, but
> the best I can manage with my current knowledge.
>   
ha, we reached similar solutions -) 

the solution for the inclusion is in

\startMPenvironment
\stopMPenvironment 

when this becomes a module, one can best append the code loading to 

  \everyMPTEXgraphic

as in 

\appendtoks 
  \usemodule[...]% 
\to \everyMPTEXgraphic 

so that it will not clash with user defined environments and/or inclusions 

Hans 

-----------------------------------------------------------------
                                          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
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: using symbols in MetaFun
  2006-02-13 10:44 ` Hans Hagen
@ 2006-02-15 15:42   ` Mojca Miklavec
  0 siblings, 0 replies; 5+ messages in thread
From: Mojca Miklavec @ 2006-02-15 15:42 UTC (permalink / raw)


Thank you very much to both of you! This works perfectly and just the
way I wanted.

I have some other questions, but I have to write exact specification(s) first.

(The whole documentation for implementing 3D features is approximately
"read the cryptic implementation in PostScript, figure out what it
does and implement it that way in your terminal". I hate that, but
I'll try to come through it. I'll report as soon as there will be
something functional available.)

Thanks a lot for all the help,
    Mojca


On 2/13/06, Hans Hagen wrote:
> 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}}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-15 15:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-11  4:28 using symbols in MetaFun Mojca Miklavec
2006-02-12 19:03 ` Taco Hoekwater
2006-02-13 11:22   ` Hans Hagen
2006-02-13 10:44 ` Hans Hagen
2006-02-15 15:42   ` Mojca Miklavec

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).