Re: [NTG-context] MetaPost instance mechanism broken

2012-12-06 Thread Marco Patzer
On 2012–11–25 Marco Patzer wrote:

 in one of the last few betas the MetaPost instance
 mechanism broke.

Did the interface change again? The following does not work on
today's beta, only “alpha” and “gamma” are printed.

\defineMPinstance
  [myinstance]
  [metafun]

\startuseMPgraphic{alpha}
  draw textext(alpha) ;
\stopuseMPgraphic

\startuseMPgraphic{myinstance::beta}
  draw textext(beta) ;
\stopuseMPgraphic

\starttext
  \useMPgraphic{alpha}
  \useMPgraphic{myinstance::beta}
  \startMPcode{myinstance}
draw textext(gamma) ;
  \stopMPcode
\stoptext


Marco

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

Re: [NTG-context] MetaPost instance mechanism broken

2012-12-06 Thread Hans Hagen

On 12/6/2012 8:10 PM, Marco Patzer wrote:

On 2012–11–25 Marco Patzer wrote:


in one of the last few betas the MetaPost instance
mechanism broke.


Did the interface change again? The following does not work on
today's beta, only “alpha” and “gamma” are printed.

\defineMPinstance
   [myinstance]
   [metafun]

\startuseMPgraphic{alpha}
   draw textext(alpha) ;
\stopuseMPgraphic

\startuseMPgraphic{myinstance::beta}
   draw textext(beta) ;
\stopuseMPgraphic

\starttext
   \useMPgraphic{alpha}
   \useMPgraphic{myinstance::beta}
   \startMPcode{myinstance}
 draw textext(gamma) ;
   \stopMPcode
\stoptext


sure, we have a different interface on odd days

Currently instances are played with a bit (as Alan and I want the 
chemical module to run in its own but also want it to be public).


Anyhow, one complication is in the related variables. I now have a 
version that supports this:


\defineMPinstance
  [myinstance]
  [metafun]

\startuseMPgraphic{alpha}
draw textext(alpha) ;
\stopuseMPgraphic

\startuseMPgraphic{myinstance::beta}
  draw textext(beta) ;
\stopuseMPgraphic

\startuniqueMPgraphic{myinstance::beta}{width}
  draw textext(beta) xsized \MPvar{width} ;
\stopuniqueMPgraphic

\startuseMPgraphic{myinstance::epsilon}{width,height}
  draw textext(epsilon) xysized (\MPvar{width},\MPvar{height}) ;
\stopuseMPgraphic

\setMPvariables
  [myinstance::beta]
  [width=5cm]

\setMPvariables
  [epsilon]
  [width=5cm,
   height=5cm]

\starttext

one   : \useMPgraphic{alpha} \blank

two   : \useMPgraphic{myinstance::beta} \blank

three : \startMPcode{myinstance} draw textext(gamma) ; 
\stopMPcode \blank


four  : \reuseMPgraphic{myinstance::beta}{width=2cm} \blank

five  : \startMPcode{myinstance} draw textext(delta) ; 
\stopMPcode \blank


six   : \reuseMPgraphic{myinstance::epsilon}{height=2cm} \blank

seven : \reuseMPgraphic{myinstance::epsilon} \blank

\stoptext

Hans


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

Re: [NTG-context] MetaPost instance mechanism broken

2012-11-26 Thread Sietse Brouwer
Aditya wrote:
 I am still using the old 2012.11.16 version, but now you have to specify
 the instance in the \startuseMPgraphic as well (Hans had announced this
 on the mailing list a few weeks ago):
 \startuseMPgraphic{instance::mygraphic}
 ...
 \stopuseMPgraphic

Since I don't use MetaPost, I don't think I'm the best person to
document this. But I took this as an opportunity to create the command
reference pages for a bunch of the \...MP... commands; perhaps one of
you could add this info to the proper page(s)? E.g. at
http://wiki.contextgarden.net/Command/startuseMPgraphic
There is an overview of the new stubs at
http://wiki.contextgarden.net/Template:MetaPost_see_also

Also: a question about
\startuseMPgraphic and
\startuniqueMPgraphic.
Both are supposed to be recompiled at every usage, so how are they
different? Actually trying it out suggests that useMPgraphic is the
only one of the two that re-evaluates its code every time; compare the
examples at
* http://wiki.contextgarden.net/Command/startuseMPgraphic and
* http://wiki.contextgarden.net/Command/startuniqueMPgraphic
But then \startuniqueMPgraphic would be the same as
\startreuseMPgraphic, so I think I'm still missing something.

Cheers,
Sietse
___
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
___


Re: [NTG-context] MetaPost instance mechanism broken

2012-11-26 Thread Marco Patzer
2012-11-26 Sietse Brouwer:

 Since I don't use MetaPost, I don't think I'm the best person to
 document this. But I took this as an opportunity to create the command
 reference pages for a bunch of the \...MP... commands; perhaps one of
 you could add this info to the proper page(s)?

Thanks. I added some info about the change mentioned in this thread.

 Also: a question about
 \startuseMPgraphic and
 \startuniqueMPgraphic.
 Both are supposed to be recompiled at every usage, so how are they
 different? Actually trying it out suggests that useMPgraphic is the
 only one of the two that re-evaluates its code every time; compare the
 examples at

AFAIK useMPgraphic is always recalculated, reusableMPgraphic never
is. uniqueMPgraphic takes the size into account and recalculates if
the graphic dimensions change. If I recall correctly this is
mentioned somewhere in the MetaFun manual. But I agree, all these
commands for including MP graphics are confusing, given the fact
that one can survive pretty well with only useMPgraphic. I attached
a small example to show the difference.


Marco
\startuseMPgraphic{alpha}
	fill unitsquare
		xyscaled (\overlaywidth, \overlayheight)
		withcolor (uniformdeviate 1, uniformdeviate 1, uniformdeviate 1);
\stopuseMPgraphic

\defineoverlay
	[alpha]
	[\useMPgraphic{alpha}]

\startreusableMPgraphic{beta}
	fill unitsquare
		xyscaled (\overlaywidth, \overlayheight)
		withcolor (uniformdeviate 1, uniformdeviate 1, uniformdeviate 1);
\stopreusableMPgraphic

\defineoverlay
	[beta]
	[\reuseMPgraphic{beta}]

\startuniqueMPgraphic{gamma}
	fill unitsquare
		xyscaled (\overlaywidth, \overlayheight)
		withcolor (uniformdeviate 1, uniformdeviate 1, uniformdeviate 1);
\stopuniqueMPgraphic

\defineoverlay
	[gamma]
	[\uniqueMPgraphic{gamma}]

\starttext

\dontleavehmode
\framed[background=alpha]{foo}
\framed[background=alpha]{foo}
\framed[background=alpha]{foobar}

\dontleavehmode
\framed[background=beta]{foo}
\framed[background=beta]{foo}
\framed[background=beta]{foobar}

\dontleavehmode
\framed[background=gamma]{foo}
\framed[background=gamma]{foo}
\framed[background=gamma]{foobar}

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

Re: [NTG-context] MetaPost instance mechanism broken

2012-11-26 Thread Aditya Mahajan

On Mon, 26 Nov 2012, Marco Patzer wrote:


2012-11-26 Sietse Brouwer:


Since I don't use MetaPost, I don't think I'm the best person to
document this. But I took this as an opportunity to create the command
reference pages for a bunch of the \...MP... commands; perhaps one of
you could add this info to the proper page(s)?


Thanks. I added some info about the change mentioned in this thread.


Also: a question about
\startuseMPgraphic and
\startuniqueMPgraphic.
Both are supposed to be recompiled at every usage, so how are they
different? Actually trying it out suggests that useMPgraphic is the
only one of the two that re-evaluates its code every time; compare the
examples at


AFAIK useMPgraphic is always recalculated, reusableMPgraphic never
is. uniqueMPgraphic takes the size into account and recalculates if
the graphic dimensions change. If I recall correctly this is
mentioned somewhere in the MetaFun manual. But I agree, all these
commands for including MP graphics are confusing, given the fact
that one can survive pretty well with only useMPgraphic. I attached
a small example to show the difference.


The distinction was more important in MkII when extra runs for different 
MP graphics could take a lot of time. But it MkIV, the difference in 
performance is, I believe, inconsequential.


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


Re: [NTG-context] MetaPost instance mechanism broken

2012-11-26 Thread Hans Hagen

On 11/26/2012 5:10 PM, Marco Patzer wrote:

2012-11-26 Sietse Brouwer:


Since I don't use MetaPost, I don't think I'm the best person to
document this. But I took this as an opportunity to create the command
reference pages for a bunch of the \...MP... commands; perhaps one of
you could add this info to the proper page(s)?


Thanks. I added some info about the change mentioned in this thread.


Also: a question about
\startuseMPgraphic and
\startuniqueMPgraphic.
Both are supposed to be recompiled at every usage, so how are they
different? Actually trying it out suggests that useMPgraphic is the
only one of the two that re-evaluates its code every time; compare the
examples at


AFAIK useMPgraphic is always recalculated, reusableMPgraphic never
is. uniqueMPgraphic takes the size into account and recalculates if
the graphic dimensions change. If I recall correctly this is


Can be more than dimensions. This is the default hash:

\def\overlaystamp
  {\overlaywidth :%
   \overlayheight:%
   \overlaydepth :%
   \MPcolor\overlaycolor:%
   \MPcolor\overlaylinecolor}

so: width, height, depth, background color, line color

but is one says

\startuniqueMPgraphic{mygraphic}{linewidth,.}

given that linewidth is set, those values are also taken into account


mentioned somewhere in the MetaFun manual. But I agree, all these
commands for including MP graphics are confusing, given the fact
that one can survive pretty well with only useMPgraphic. I attached
a small example to show the difference.


It does make a difference when you have documents with thousands of 
graphics (mkiv is much faster btw) and the pdf file is also smaller when 
reuse is applied


Hans


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


Re: [NTG-context] MetaPost instance mechanism broken

2012-11-25 Thread Wolfgang Schuster

Am 25.11.2012 um 18:11 schrieb Marco Patzer home...@lavabit.com:

 Hi,
 
 in one of the last few betas the MetaPost instance
 mechanism broke.
 
 \defineMPinstance
  [myinstance]
  [metafun]
 
 \startuseMPgraphic{mympgraphic}
  fill fullsquare scaled 1cm withcolor blue;
 \stopuseMPgraphic
 
 \starttext\null
  \useMPgraphic{myinstance::mympgraphic}
 \stoptext


The problem lies in the \uniqueMPgraphic and \useMPgrpahic commands. There is a 
commented
line in each command which is the correct setting and the next line is wrong.

\def\meta_unique_page_graphic#1#2%
  {\meta_begin_graphic_group{#1}%
   \let\overlaystamp\overlaypagestamp
   \setupMPvariables[\m_meta_page_prefix:\currentMPgraphicname][#2]% prefix is 
new here
%\getvalue{\??mpgraphic\m_meta_page_prefix:\currentMPgraphicname}{}%
   \getvalue{\??mpgraphic\m_meta_page_prefix:#1}{}%
   \meta_end_graphic_group}

\def\meta_use_graphic#1#2%
  {\meta_begin_graphic_group{#1}%
   \doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}%
  %\getvalue{\??mpgraphic\currentMPgraphicname}\empty
   \getvalue{\??mpgraphic#1}\empty
   \meta_end_graphic_group}

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


Re: [NTG-context] MetaPost instance mechanism broken

2012-11-25 Thread Aditya Mahajan

On Sun, 25 Nov 2012, Marco Patzer wrote:


Hi,

in one of the last few betas the MetaPost instance
mechanism broke.

\defineMPinstance
 [myinstance]
 [metafun]

\startuseMPgraphic{mympgraphic}
 fill fullsquare scaled 1cm withcolor blue;
\stopuseMPgraphic

\starttext\null
 \useMPgraphic{myinstance::mympgraphic}
\stoptext


I am still using the old 2012.11.16 version, but now you have to specify 
the instance in the \startuseMPgraphic as well (Hans had announced this 
on the mailing list a few weeks ago):


\startuseMPgraphic{instance::mygraphic}
...
\stopuseMPgraphic


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


Re: [NTG-context] MetaPost instance mechanism broken

2012-11-25 Thread Marco Patzer
2012-11-25 Aditya Mahajan:


 I am still using the old 2012.11.16 version, but now you have to specify 
 the instance in the \startuseMPgraphic as well (Hans had announced this 
 on the mailing list a few weeks ago):

I missed that.

 \startuseMPgraphic{instance::mygraphic}
 ...
 \stopuseMPgraphic

This works. Thanks to both of you, Wolfgang and Aditya.


Marco

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