The following code is an example of how to draw a graphic on every page of a document. The graphic (a grey rectangle) appears in a different place for each chapter, and the chapter number appears in the rectangle as well. This is often called a thumb index - your thumb can flip the pages of a book while you watch the contents flash past...
<texcode>
% by Hans Hagen, of course :-)
<context source="yes">% these first lines are just for wiki layout and visualisation\unprotected setuppapersize[A8][A5,landscape] \showframe\setuppaper[nx=4,ny=2]\setuparranging[XY]\usemodule[visual] \def\rawsectionnumber#1currentchapternumber {\countervaluesomenamedheadnumber{chapter}{current}} \??se#1def\lastchapternumber {\somenamedheadnumber{chapter}{last}} % will be in kernel
\setuppagenumbering
[alternative=doublesided]
\setupcolors
[state=start]
\setupbackgrounds
[\setups{thumbs}]
\defnewdimen\NOfChapters{4} % i need to make this one availablethumbheight
An example (MkIV) for using Metapost to create thumb indices for chapters.
<texcodecontext source="yes">% these first lines are just for wiki layout and visualisation\setuppapersize[A8][A4]\showframe\setuppaper[A4nx=4,oversizedny=4]\setuparranging[XY]\usemodule[visual]
\setuplayout
\starttext \showframe
\dorecurse{63}{\chapter{Test Chapter #1} Chapter \somestructureheadnumbersomeheadnumber[chapter][current] of \somestructureheadnumbersomeheadnumber[chapter][last]