Open main menu

Changes

m
* The first parameter sets the main layout area;
* the optional second one specifies the linked subarea(s) of the prior. Not all main areas have such subareas.
* about the third parameter, ** the key <code>state</code> determines when the page background is recalculated. ***<ttcode>state=repeat</ttcode> ensures that the page background is always recalculated (useful if you want to use a variable that depends on the current page, such as its number with {{cmd|realpageno}}). *** <ttcode>state=stopstart</ttcode> recalculates the page background, and stops its automatic recalculation,*** <ttcode>state=startstop</ttcode> stop doesn't recalculate the page background, and start recalculationsstops its automatic recalculation.
Because {{cmd|showframe}} and {{cmd|setupbackgrounds}} both draw frameboxes over parts of the page, the order in which they are invoked matters. In most cases, {{cmd|setupbackgrounds}} should come last.
Backgrounds are essential for working with [[Layers]]. You enable your defined layers like <code>\setupbackgrounds[page][background=mylayer]</code>.
The <ttcode>background</ttcode> key also takes a list, and if you include "foreground", you can also set something on top of your general content, e.g. <code>\setupbackgrounds[page][background={mybacklayer,foreground,mytoplayer}]</code>.
== Example ==
<context source=yes>
\setuppapersize[A10A7]
\showframe
% \setupbackgrounds should be placed *after* \showframe,
\setupbackgrounds[footer] [background=color, backgroundcolor=blue]\setupbackgrounds[footer] [leftmargin] [background=color, backgroundcolor=red]\setupbackgrounds [text] [background=color, backgroundcolor=lightgray]\setupbackgrounds [text] [rightmargin] [background=color, backgroundcolor=yellow]
\starttextI paint modern\stoptext</context> === Example of dynamic positioning of page numbering === <context source=yes>\setuppapersize[A6][A6]\setupbackgrounds[textstate=repeat] [background%\showframe\startuseMPgraphic{MonGraphismeV_MP} numeric h ; h := \overlayheight ; numeric w ; w := \overlaywidth ; numeric n ; n := \number\realpageno ; numeric m ; m := \number\lastpageno ; numeric ratio ; ratio := (1-n/(m+1)); numeric e ; e := 0.3mm;  picture pa ; pa := textext.raw(btex {\strut\the\realpageno} etex) ; numeric wpa ; wpa := xpart (urcorner pa - ulcorner pa); numeric hpa ; hpa := ypart (ulcorner pa - llcorner pa);  pa := pa shifted (-wpa/2 + w/2, ratio * (h-hpa)); pair paA ; paA:= ((ulcorner pa) + (urcorner pa)) / 2 ; pair paB ; paB:= ((llcorner pa) + (lrcorner pa)) / 2 ;  draw ((w/2,0)--paB) dashed withdots withpen pencircle scaled e withcolor darkred; draw ((w/2,h)--paA) dashed withdots withpen pencircle scaled e withcolor darkred; draw pa withcolor darkred;\stopuseMPgraphic \startuseMPgraphic{MonGraphismeH_MP} numeric h ; h := \overlayheight ; numeric w ; w := \overlaywidth ; numeric n ; n := \number\realpageno ; numeric m ; m := \number\lastpageno ; numeric ratio ; ratio := (n/(m+1)); numeric e ; e := 0.3mm;  picture pa ; pa := textext.raw(btex {\strut\the\realpageno} etex) ; numeric wpa ; wpa := xpart (urcorner pa - ulcorner pa); numeric hpa ; hpa := ypart (ulcorner pa - llcorner pa);  pa :=colorpa shifted (ratio * (w-wpa), backgroundcolor-hpa/2 + h/2); pair paA ; paA:=lightgray((ulcorner pa) + (llcorner pa)) / 2 ; pair paB ; paB:= ((urcorner pa) + (lrcorner pa)) / 2 ;  draw ((0,h/2)--paA) dashed withdots withpen pencircle scaled e withcolor darkred; draw ((w,h/2)--paB) dashed withdots withpen pencircle scaled e withcolor darkred; draw pa withcolor darkred;\stopuseMPgraphic \defineoverlay [MonGraphismeV_OL] [\useMPgraphic{MonGraphismeV_MP}]\defineoverlay [MonGraphismeH_OL] [\useMPgraphic{MonGraphismeH_MP}] \setupbackgrounds[text] [rightmargin] [background=color, backgroundcolor{MonGraphismeV_OL}]\setupbackgrounds [footer] [text] [background=yellow{MonGraphismeH_OL}\starttext \dorecurse{4}{\input tufte\page}
I paint modern\stoptext
</context>
1,005

edits