[NTG-context] different page background for chapter title page

Hans Hagen pragma at wxs.nl
Sat Mar 23 13:27:47 CET 2013


Hi,

You know the price you have to pay: wikifying ..


\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}] % could be drawn in 
one go

\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

Of course more solutions are possible. Btw, watch the topboundary 
trickery and the fractional color.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list