ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Mojca Miklavec" <mojca.miklavec.lists@gmail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: How does MPinclusions work in mkiv?
Date: Tue, 2 Sep 2008 13:13:05 +0200	[thread overview]
Message-ID: <6faad9f00809020413x5b09647en894e0e9830792223@mail.gmail.com> (raw)

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
___________________________________________________________________________________


             reply	other threads:[~2008-09-02 11:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-02 11:13 Mojca Miklavec [this message]
2008-09-02 11:31 ` Wolfgang Schuster
2008-09-02 17:56 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6faad9f00809020413x5b09647en894e0e9830792223@mail.gmail.com \
    --to=mojca.miklavec.lists@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).