How does the following code work? Source: discussion on the mailing list
\setuplayout
[header=0cm,
topspace=1.625cm,
footer=0cm,
width=fit,
height=fit]
\startMPinclusions
numeric MyTitlePageDone[] ;
\stopMPinclusions
\startuseMPgraphic{background:normal}
StartPage ;
fill
(topboundary Page --cycle) enlarged(0,5mm) shifted (0,-5mm)
withcolor \MPcolor{color:background:\namedstructureuservariable{chapter}{mycolor}} ;
StopPage ;
\stopuseMPgraphic
\defineoverlay
[background:normal]
[\useMPgraphic{background:normal}]
\startuseMPgraphic{background:title}
if unknown MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} :
StartPage ;
fill ((topboundary Page --cycle) enlarged(0,5mm))
shifted (0,-20mm)
withcolor \MPcolor{color:title:\namedstructureuservariable{chapter}{mycolor}} ;
StopPage ;
MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} := 1 ;
fi ;
\stopuseMPgraphic
\defineoverlay
[background:title]
[\useMPgraphic{background:title}]
\setupbackgrounds
[page]
[background={background:normal,background:title}]
\definecolor [color:title:one] [r=0.86,g=0.88,b=0.76]
\definecolor [color:background:one] [.9(color:title:one)]
\definecolor [color:title:two] [g=0.86,r=0.88,b=0.76]
\definecolor [color:background:two] [.9(color:title:two)]
\starttext
\startchapter[title=One][mycolor=one]
\input tufte \page
\input knuth
\stopchapter
\startchapter[title=Two][mycolor=two]
\input tufte \page
\input knuth
\stopchapter
\stoptext
Why are the backgrounds being applied conditionally? Why isn't the title page background applied to normal pages? In the code there doesn't seem to be any conditionals or checks to check the page type. The title background also gets applied to cover pages implemented via \startstandardmakeup, but gets a black color instead since the user variable isn't defined.
Some help in understanding this code is much appreciated.