How does MPinclusions work in mkiv?
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
On Tue, Sep 2, 2008 at 1:13 PM, Mojca Miklavec
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
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 -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Mojca Miklavec
-
Wolfgang Schuster