* How does MPinclusions work in mkiv?
@ 2008-09-02 11:13 Mojca Miklavec
2008-09-02 11:31 ` Wolfgang Schuster
2008-09-02 17:56 ` Hans Hagen
0 siblings, 2 replies; 3+ messages in thread
From: Mojca Miklavec @ 2008-09-02 11:13 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hello (Hans),
this "minimal" example worked OK in mkiv back in May (most of settings
in the code below are just unimportant cosmetics, but otherwise it's
difficult to explain the idea behind); now it still works in mkii, but
not in mkiv.
\def\mynextmpgraphic{\startMPinclusions erase_picture := 1; \stopMPinclusions}
\startusableMPgraphic{bubble}
if erase_picture = 0:
draw last_picture;
else:
% draw a new picture; in mkiv this code is only reached once,
% \mynextgraphic does not reset erase_picture
fi;
\stopusableMPgraphic
The code is ugly anyway, I know, but how should I reset variables to
redraw the picture once more?
Thanks a lot,
Mojca
-------------------
\setupcolors[state=start]
\definecolor[color 1][r=.7,g=.0,b=.0]
\definecolor[color 2][r=.7,g=.35,b=.0]
\definecolor[color 3][r=.67,g=.7,b=.0]
\definecolor[color 4][r=.3,g=.7,b=.0]
\definecolor[color 5][r=.0,g=.7,b=.0]
\definecolor[color 6][r=.0,g=.7,b=.4]
\definecolor[color 7][r=.0,g=.6,b=.7]
\definecolor[color 8][r=.0,g=.3,b=.7]
\definecolor[color 9][r=.1,g=.0,b=.7]
\definecolor[color 10][r=.4,g=.0,b=.7]
\definecolor[pagecolor][color 1]
\setuphead
[section]
[number=no,
page=yes,
style=\bfd,
color=pagecolor]
\setuppapersize
[S6][S6]
\setuppagenumbering
[location=]
\definelayer
[page]
[width=\paperwidth,
height=\paperheight]
\setupbackgrounds
[page]
[background=bubble]
\defineoverlay
[bubble]
[\useMPgraphic{bubble}]
\startMPinclusions
picture last_picture;
last_picture := nullpicture;
erase_picture := 1;
\stopMPinclusions
\startusableMPgraphic{bubble}
if erase_picture = 0:
draw last_picture;
else:
for i=1 upto 20:
path p; p := fullcircle
scaled (2cm+uniformdeviate(3cm))
shifted (uniformdeviate(\overlaywidth),uniformdeviate(\overlayheight));
fill p withcolor .2[white,\MPcolor{pagecolor}];
draw p withcolor .5[white,\MPcolor{pagecolor}];
endfor;
setbounds currentpicture to unitsquare xyscaled
(\overlaywidth,\overlayheight);
last_picture := currentpicture;
erase_picture := 0;
fi;
\stopusableMPgraphic
\def\mynextmpgraphic{\startMPinclusions erase_picture := 1; \stopMPinclusions}
\starttext
\section{abc first time}
\section{abc second time}
\section{abc third time}
\page\definecolor[pagecolor][color 2]\mynextmpgraphic\page
\section{def first time}
\section{def second time}
\section{def third time}
\page\definecolor[pagecolor][color 3]\mynextmpgraphic\page
\section{ghi first time}
\section{ghi second time}
\page\definecolor[pagecolor][color 4]\mynextmpgraphic\page
\section{jkl first time}
\section{jkl second time}
\section{jkl third time}
\section{jkl fourth time}
\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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does MPinclusions work in mkiv?
2008-09-02 11:13 How does MPinclusions work in mkiv? Mojca Miklavec
@ 2008-09-02 11:31 ` Wolfgang Schuster
2008-09-02 17:56 ` Hans Hagen
1 sibling, 0 replies; 3+ messages in thread
From: Wolfgang Schuster @ 2008-09-02 11:31 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Tue, Sep 2, 2008 at 1:13 PM, Mojca Miklavec
<mojca.miklavec.lists@gmail.com> wrote:
> Hello (Hans),
>
> this "minimal" example worked OK in mkiv back in May (most of settings
> in the code below are just unimportant cosmetics, but otherwise it's
> difficult to explain the idea behind); now it still works in mkii, but
> not in mkiv.
>
> \def\mynextmpgraphic{\startMPinclusions erase_picture := 1; \stopMPinclusions}
>
> \startusableMPgraphic{bubble}
> if erase_picture = 0:
> draw last_picture;
> else:
> % draw a new picture; in mkiv this code is only reached once,
> % \mynextgraphic does not reset erase_picture
> fi;
> \stopusableMPgraphic
>
> The code is ugly anyway, I know, but how should I reset variables to
> redraw the picture once more?
>
> Thanks a lot,
> Mojca
>
> -------------------
>
> \setupcolors[state=start]
> \definecolor[color 1][r=.7,g=.0,b=.0]
> \definecolor[color 2][r=.7,g=.35,b=.0]
> \definecolor[color 3][r=.67,g=.7,b=.0]
> \definecolor[color 4][r=.3,g=.7,b=.0]
> \definecolor[color 5][r=.0,g=.7,b=.0]
> \definecolor[color 6][r=.0,g=.7,b=.4]
> \definecolor[color 7][r=.0,g=.6,b=.7]
> \definecolor[color 8][r=.0,g=.3,b=.7]
> \definecolor[color 9][r=.1,g=.0,b=.7]
> \definecolor[color 10][r=.4,g=.0,b=.7]
> \definecolor[pagecolor][color 1]
>
> \setuphead
> [section]
> [number=no,
> page=yes,
> style=\bfd,
> color=pagecolor]
> \setuppapersize
> [S6][S6]
> \setuppagenumbering
> [location=]
> \definelayer
> [page]
> [width=\paperwidth,
> height=\paperheight]
?
> \setupbackgrounds
> [page]
> [background=bubble]
> \defineoverlay
> [bubble]
> [\useMPgraphic{bubble}]
>
> \startMPinclusions
> picture last_picture;
> last_picture := nullpicture;
> erase_picture := 1;
> \stopMPinclusions
>
> \startusableMPgraphic{bubble}
> if erase_picture = 0:
> draw last_picture;
> else:
> for i=1 upto 20:
> path p; p := fullcircle
> scaled (2cm+uniformdeviate(3cm))
> shifted (uniformdeviate(\overlaywidth),uniformdeviate(\overlayheight));
> fill p withcolor .2[white,\MPcolor{pagecolor}];
> draw p withcolor .5[white,\MPcolor{pagecolor}];
> endfor;
>
> setbounds currentpicture to unitsquare xyscaled
> (\overlaywidth,\overlayheight);
>
> last_picture := currentpicture;
> erase_picture := 0;
> fi;
> \stopusableMPgraphic
>
> \def\mynextmpgraphic{\startMPinclusions erase_picture := 1; \stopMPinclusions}
>
> \starttext
>
> \section{abc first time}
> \section{abc second time}
> \section{abc third time}
>
> \page\definecolor[pagecolor][color 2]\mynextmpgraphic\page
>
> \section{def first time}
> \section{def second time}
> \section{def third time}
>
> \page\definecolor[pagecolor][color 3]\mynextmpgraphic\page
>
> \section{ghi first time}
> \section{ghi second time}
>
> \page\definecolor[pagecolor][color 4]\mynextmpgraphic\page
>
> \section{jkl first time}
> \section{jkl second time}
> \section{jkl third time}
> \section{jkl fourth time}
>
> \stoptext
Write the test in TeX, the information will not be lost in this way.
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How does MPinclusions work in mkiv?
2008-09-02 11:13 How does MPinclusions work in mkiv? Mojca Miklavec
2008-09-02 11:31 ` Wolfgang Schuster
@ 2008-09-02 17:56 ` Hans Hagen
1 sibling, 0 replies; 3+ messages in thread
From: Hans Hagen @ 2008-09-02 17:56 UTC (permalink / raw)
To: mailing list for ConTeXt users
Mojca Miklavec wrote:
> Hello (Hans),
>
> this "minimal" example worked OK in mkiv back in May (most of settings
> in the code below are just unimportant cosmetics, but otherwise it's
> difficult to explain the idea behind); now it still works in mkii, but
> not in mkiv.
>
> \def\mynextmpgraphic{\startMPinclusions erase_picture := 1; \stopMPinclusions}
>
> \startusableMPgraphic{bubble}
> if erase_picture = 0:
> draw last_picture;
> else:
> % draw a new picture; in mkiv this code is only reached once,
> % \mynextgraphic does not reset erase_picture
> fi;
> \stopusableMPgraphic
>
> The code is ugly anyway, I know, but how should I reset variables to
> redraw the picture once more?
actually in mkii this will also happen ...
texexec --automp verypink.tex
but the real solution for your problem is
\def\mynextmpgraphic{\startMPinitializations erase_picture := 1;
\stopMPinitializations}
the inclusions happen once per (whole) run, and the initializations
happen per graphic
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
-----------------------------------------------------------------
___________________________________________________________________________________
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-02 17:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-02 11:13 How does MPinclusions work in mkiv? Mojca Miklavec
2008-09-02 11:31 ` Wolfgang Schuster
2008-09-02 17:56 ` Hans Hagen
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).