% output=pdftex
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\environment back-0

\setupindenting[big]

\starttext

\definecolumnset[two][n=3]
\definecolumnsetspan[test]

\definetextbackground[test]
  [background=color,
   mp=mpos:par:columnset:shade,
   methode=mpos:par:columnset,
   backgroundcolor=red]

\definetextbackground[more]
  [background=color,backgroundcolor=green,
   mp=mpos:par:columnset:shade,
   methode=mpos:par:columnset,
   alternative=1,rulethickness=2pt]

\startuseMPgraphic{mpos:par:columnset:shade}
  for i=1 upto nofmultipars :
    if     multilocs[i]=1 : fill multipars[i] withcolor .5[red,  white] ;
    elseif multilocs[i]=2 : fill multipars[i] withcolor .5[green,white] ;
    else                  : fill multipars[i] withcolor .5[blue, white] ;
    fi ;
  endfor ;
\stopuseMPgraphic


\startcolumnset[two]

\startcolumnsetspan[test]
  \input tufte
\stopcolumnsetspan

%\placefigure[btlr]{}{\framed{test}}

\starttextbackground[test]

\input tufte \par

\startnarrower

  \starttextbackground[more]

  \input tufte \par

%  \placefigure{}{\framed{test}}

  \input tufte \par

  \input tufte \par

  \input tufte \par

  \input tufte \par

  \input tufte

  \stoptextbackground

\stopnarrower

\stoptextbackground

\input tufte

\starttextbackground[more] \input tufte \stoptextbackground

\starttextbackground[test] \input tufte \stoptextbackground

\starttextbackground[more] \input tufte \stoptextbackground

% \placefigure{}{\externalfigure[cow.pdf]}

%\starttabulate[|l|p|l|]
%\NC x
%\NC \txx \starttextbackground[test] \input tufte \stoptextbackground
%\NC x \NC \NR
%\stoptabulate

%\starttabulate[|l|p|p|l|]
%\NC x
%\NC \txx \starttextbackground[test] \input tufte \stoptextbackground
%\NC \txx \starttextbackground[more] \input tufte \stoptextbackground
%\NC x \NC \NR
%\stoptabulate
%
%\starttabulate[|l|p|p|p|p|l|]
%\NC x
%\NC \starttextbackground[test]www\stoptextbackground
%\NC \starttextbackground[test]xxx\stoptextbackground
%\NC \starttextbackground[more]yyy\stoptextbackground
%\NC \starttextbackground[test]zzz\stoptextbackground
%\NC x \NC \NR
%\stoptabulate

\stopcolumnset

\stoptext
