\startMPdefinitions
input boxes;
primarydef a +- b =
a -- (xpart a, ypart b) -- b
enddef ;
primarydef a -+ b =
a -- (xpart b, ypart a) -- b
enddef ;
\stopMPdefinitions
\defineframed
[boxframed]
[
width=6em,
height=2\lineheight,
align={middle,lohi},
background=color,
backgroundcolor=blue,
foregroundcolor=white,
forefroundstyle=bold,
]
\startuseMPgraphic[offset=2mm]{boxes}
boxit.A("\boxframed{Box A}");
boxit.B("\boxframed{Box B}");
boxit.C("\boxframed{Box C}");
defaultdx := 0pt;
defaultdy := 0pt;
A.c = origin;
B.w - A.e = (1cm, 0);
0.5[ A.s, B.s ] - C.n = (0, 1cm);
stacking := 0;
drawunboxed(A,B,C);
stacking := 1;
drawarrow A.s +- C.w ;
drawarrow B.s +- C.e ;
newpath highlight;
highlight
:= (A.sw
-- B.se -- B.ne
-- A.nw
) enlarged EmWidth;
fill highlight withcolor "darkgray" withstacking -1;
\stopuseMPgraphic
\starttext
\useMPgraphic[stacking={0}]{boxes}
\useMPgraphic[stacking={0,1}]{boxes}
\useMPgraphic[stacking=-1]{boxes}
\stoptext