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

\environment back-0

\startuseMPgraphic{mpos:par:columnset:shade}
  path p ; numeric h ; 
  for i=1 upto nofmultipars : 
    p := multipars[i] ;
    h := bbheight(p) ; 
    if     multilocs[i]=1 :  
      linear_shade(p,                    8,boxfillcolor,white) ; 
    elseif multilocs[i]=2 : 
      linear_shade(p topenlarged    -.5h,8,boxfillcolor,white) ; 
      linear_shade(p bottomenlarged -.5h,8,white,boxfillcolor) ; 
    else :
      linear_shade(p,                    8,white,boxfillcolor) ; 
    fi ;
  endfor ; 
\stopuseMPgraphic

\startuseMPgraphic{mpos:par:columnset:shade}
  path p, q, r ; numeric h ; 
  for i=1 upto nofmultipars : 
    p := multipars[i] ;
    h := bbheight(p) ; 
    q := multipars[i] topenlarged    -.5h ;
    r := multipars[i] bottomenlarged -.5h ;
    if     multilocs[i] = 1 : 
      linear_shade(p,8,boxfillcolor,white) ; 
    elseif multilocs[i] = 2 : 
      linear_shade(q,8,boxfillcolor,white) ; 
      linear_shade(r,8,white,boxfillcolor) ; 
    else :
      linear_shade(p,8,white,boxfillcolor) ; 
    fi ;
  endfor ; 
\stopuseMPgraphic

\definecolumnset
  [three]
  [n=3,
   distance=.5cm]

\definetextbackground
  [shade]
  [location=paragraph,
   backgroundcolor=shadecolor,
   mp=mpos:par:columnset:shade,
   methode=mpos:par:columnset,
   leftoffset=\topskipgap, 
   before=\blank,
   after=\blank]

\starttext

\startcolumnset[three] 

\dorecurse{10}
  {\starttextbackground[shade]
     \fakewords{10}{500}
   \stoptextbackground}

\stopcolumnset 

\stoptext
