\setuppapersize
[S6][S6]
\setupbodyfont
[pos,10pt]
\setuplayout
[topspace=0cm,
backspace=0cm,
header=0pt,
footer=0pt,
width=middle,
height=middle]
\setupcolors
[state=start]
\definecolor[TextColor][s=.9]
\definecolor[PageColor][r=.5,g=.4,b=.3]
\definecolor[LineColor][r=.7,g=.6,b=.5]
\definecolor[ColorPage][r=.5,g=.6,b=.7]
\definecolor[ColorLine][r=.3,g=.4,b=.5]
\setupinteraction
[state=start,
display=new]
\setupinteractionscreen
[option=max]
\defineoverlay [page] [\uniqueMPgraphic{page}]
\defineoverlay [graphic] [\uniqueMPgraphic{graphic}]
\defineoverlay [number] [\uniqueMPgraphic{number}]
\defineoverlay [nextpage] [\overlaybutton{nextpage}]
\defineoverlay [previouspage] [\overlaybutton{previouspage}]
\defineoverlay [forward] [\overlaybutton{forward}]
\definelayer [main]
\defineoverlay [main] [\composedlayer{main}]
\setupbackgrounds
[page]
[background={previouspage,page}]
\setupbackgrounds
[text]
[background={main,idea}]
\defineframedtext
[PageText]
[width=fit,offset=.5cm,
before=,after=,frame=off,background={number,forward}]
\defineframedtext
[SampleText]
[width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
before=,after=,frame=off,background={graphic,sample,nextpage}]
\defineframedtext
[TextText]
[width=.6\makeupwidth,height=fit,offset=2cm,align=middle,
before=,after=,frame=off,background={text,nextpage}]
\def\StartIdea
{\null \dontcomplain}
\def\StopIdea
{\setlayer
[main]
[x=\makeupwidth,y=.5cm,hoffset=-.5cm,location=lb]
{\PageText{\pagenumber}}
\page}
\def\StartSample
{\setlayer
[main]
[hoffset=.75cm,voffset=.75cm]
\bgroup \hpos {SampText:\realfolio} \bgroup \startSampleText [none]}
\def\StopSample
{\stopSampleText \egroup \egroup}
\def\StartText
{\setMPpositiongraphic
{TextText:\realfolio}{text}{other=SampText:\realfolio}
\setlayer
[main]
[x=\makeupwidth,y=\makeupheight,
hoffset=-.75cm,voffset=-.75cm,
location=lt]
\bgroup \noindent \hpos {TextText:\realfolio} \bgroup \startTextText [none]}
\def\StopText
{\stopTextText \egroup \egroup}
\startuniqueMPgraphic{page}
StartPage ;
pickup pencircle scaled .5cm ;
fill Page withcolor \MPcolor{PageColor} ;
draw Page withcolor \MPcolor{LineColor} ;
StopPage ;
\stopuniqueMPgraphic
\startuniqueMPgraphic{number}
path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
pickup pencircle scaled .25cm ;
fill p withcolor \MPcolor{TextColor} ;
draw p withcolor (white-\MPcolor{PageColor}) ;
\stopuniqueMPgraphic
\startuniqueMPgraphic{graphic}
path p ; p := fullcircle xscaled OverlayWidth yscaled OverlayHeight;
pickup pencircle scaled .5cm ;
fill p withcolor \MPcolor{TextColor} ;
draw p withcolor \MPcolor{LineColor} ;
\stopuniqueMPgraphic
\startMPpositiongraphic{text}
initialize_box(\MPpos{\MPvar{other}}) ;
path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
initialize_box(\MPpos{\MPvar{self}}) ;
path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
pickup pencircle scaled .5cm ;
fill q withcolor \MPcolor{TextColor} ;
draw p withcolor (white-\MPcolor{PageColor}) ;
clip currentpicture to q ;
draw q withcolor \MPcolor{LineColor} ;
anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic
\def\StartTitlePage
{\startstandardmakeup
\dontcomplain
\setupframedtexts[TextText][width=fit]
\StartText
\bfd\setupinterlinespace
\def\\{\blank\bfc\setupinterlinespace\def\\{\blank}}}
\def\StopTitlePage
{\StopText
\stopstandardmakeup}
\def\TitlePage#1
{\StartTitlePage#1\StopTitlePage}
\startMPpositiongraphic{text}
if box_found(\MPpos{\MPvar{other}}) :
initialize_box(\MPpos{\MPvar{other}}) ;
path p ; p := fullcircle xscaled wxy yscaled hxy shifted cxy ;
fi ;
initialize_box(\MPpos{\MPvar{self}}) ;
path q ; q := fullcircle xscaled wxy yscaled hxy shifted cxy ;
pickup pencircle scaled .5cm ;
fill q withcolor \MPcolor{TextColor} ;
if box_found(\MPpos{\MPvar{other}}) :
draw p withcolor (white-\MPcolor{PageColor}) ;
clip currentpicture to q ;
draw q withcolor \MPcolor{LineColor} ;
else :
draw q withcolor (white-\MPcolor{PageColor}) ;
fi ;
anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic
\doifnotmode{demo}{\endinput}
\starttext
\TitlePage
{Fancy Styles:\\layers}
\StartIdea
\StartSample
\input tufte
\StopSample
\StartText
\input reich
\StopText
\StopIdea
\StartIdea
\StartSample
\input knuth
\StopSample
\StartText
\input reich
\StopText
\StopIdea
\stoptext