On Thu, 19 Apr 2012, Aditya Mahajan wrote:
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?
If you know the page numbers in advance, you can also set the layer content in the preamble. \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=repeat, frame=on, ] \definelayer[test-layer:2][test-layer] \definelayer[test-layer:3][test-layer] \setMPlayer[test-layer:2]{\useMPgraphic{test-metapost-1}} \setMPlayer[test-layer:3]{\useMPgraphic{test-metapost-2}} \setupbackgrounds[page][background={test-layer}] \starttext \dorecurse{20}{\input knuth} \stoptext Aditya