On Wed, 18 Apr 2012, Raymond LeClair wrote:
I have written Python classes to automate reading a Tumblr blog and writing a
file for processing by ConTeXt. No manual editing of the ConTeXt input file is
allowed.
Photos are incorporated in a graphic created using METAPOST commands embedded
in the ConTeXt input file. Then the graphic is used as a background. I need
this background to appear only on one page.
My current solution is to use TeX conditionals to test if the page
number has incremented, then reset the background to empty. This
approach fails in many cases. The code below provides a minimum working
example of a failure. Photos are shown as squares to reduce the size of
this post.
Is there a better way to reset the background?
Use can use layers with state=reset, which automatically reset after each
page.
\startuseMPgraphic{test-metapost-1}
StartPage;
fill Page withcolor 0.25[blue,white];
StopPage;
\stopuseMPgraphic
\startuseMPgraphic{test-metapost-2}
StartPage;
fill Page withcolor 0.25[green,white];
StopPage;
\stopuseMPgraphic
\definelayer
[test-layer]
[
width=\paperwidth,
height=\paperheight,
state=reset,
frame=on,
]
\setMPlayer[test-layer]{\useMPgraphic{test-metapost-1}}
\setupbackgrounds[page][background={test-layer}]
\starttext
\dorecurse{10}{\input knuth}
\setMPlayer[test-layer]{\useMPgraphic{test-metapost-2}}
\dorecurse{10}{\input knuth}
\stoptext
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
___________________________________________________________________________________