\setuppapersize[A4,landscape][A4,landscape]
\setupcolors[state=start]
\setuplayout[topspace=1cm,
     backspace=1cm,
     header=0.7cm,
     footer=0cm,
     margin=0pt,
     width=fit, 
     height=fit]

\setupheader[style=\tfb]
\setuppagenumbering[location=]
\setupbodyfont[8pt]
\definecolor[cloudblue] [r=0.47, g=0.54, b=1] % an RGB color



\startuniqueMPgraphic{cloud}
H=\overlayheight;
W=\overlaywidth;

def d = ((uniformdeviate drift) - (drift/2)) enddef ;

vardef cloudpart (expr f,s,a,b) = % first point, second point, path, 
                                  % first direction, second direction
  drift:=20;
  f{dir ((angle a+d) - 90)} .. s{dir ((angle b+d) + 90)}
enddef;

vardef drawcloud (expr n,p) = % number of point drawn on path p
  l:=length p;
  pair here;
  path cloud;

  drift:= 2H/n;
  for i= 0 upto n-1 :
    z[i] = point (i*l/n) of p shifted (d,d);
  endfor;
  z[n] = z[1];

  cloud := cloudpart (z[0],z[1],(direction 0 of p), (direction 1*l/n of p));


  for i = 1 upto n-2:
    cloud := cloud .. cloudpart (z[i],z[i+1], direction (i*l/n) of p,
       direction ((i+1)* l/n) of p);
  endfor;
  cloud := cloud .. cloudpart (z[n-1],z[0], direction ((n-1)*l/n) of p,
      direction 0 of p) -- cycle;
  filldraw cloud;
  % debug
%%   for i= 0 upto n :
%%       draw z[i] withcolor green withpen pencircle scaled 1pt;
%%   endfor;
  
enddef;
path ell;

ell := ( unitsquare xyscaled (W,H)  enlarged 3pt)  superellipsed .80;


drawoptions (withcolor \MPcolor{cloudblue});
drawcloud (14,ell);
setbounds currentpicture to OverlayBox enlarged 15pt;

% debug
%draw ell withcolor green withpen pencircle scaled .5pt;
%draw boundingbox currentpicture withcolor green;
\stopuniqueMPgraphic


% Should look like head is marked with a highlighter 
\startuniqueMPgraphic{highlight}
def d = ((uniformdeviate drift) - (drift/2)) enddef ;

vardef randomstroke (expr w,h) =
drift := .5h;
(0+d,0+d) -- (0+d,h+d) -- (w+d,h+d) -- (w+d,0+d) -- cycle
enddef;

def highlight (expr p,n) = % path, number of strokes
save w,h;
w:=bbwidth (p);
h:=bbheight (p);
for i:= 0 upto n-1 :
   filldraw randomstroke (w,h/n) shifted (0,h/n * (i - i/n)) ;
endfor;
enddef;

drawoptions (withcolor yellow);
% 
path p; p:=OverlayBox enlarged 10pt;

highlight(p,4);
\stopuniqueMPgraphic

%\defineoverlay[myhead][\uniqueMPgraphic{cloud}]
\defineoverlay[myhead][\uniqueMPgraphic{highlight}]

\def\HeadTitle#1#2{\hbox to \hsize%
        {\hfil%
        \framed[frame=off,
                background=myhead,
                offset=overlay,
                align=middle]{#1#2}\hfil}}

\definehead[package][subject]
\setuphead [package]
  [style=ss,
   command=\HeadTitle,
   alternative=middle]

\definetabulate [package] [|l|lT|]
\let\somepackage\startpackage
\def\startpackage#1{\package{#1}\somepackage}
\def\refentry#1#2{\NC #1 \NC #2 \NC\NR}

%%% Local Variables: 
%%% mode: context
%%% TeX-master: "emacs"
%%% End: 
