%% metapost        > trace > <error> unknown string ta
%% metafun         > log >
%% metafun         > log > error: Equation cannot be performed (unknown string=vacuous)
\setupbackgrounds
  [page]
  [background={foreground,foregraphics}]

\defineoverlay [foregraphics] [\positionoverlay{foregraphics}]

\starttext

\startMPpositiongraphic{mypos:line}
  path pa, pb, pab ; numeric na, nb ; string ta, tb ;
  ta := texstr("from") ;
  tb := texstr("to") ;
  na := positionpage(ta) ;
  nb := positionpage(tb) ;
  pa := positionbox(ta) ;
  pb := positionbox(tb) ;
  pa := fullcircle xsized (bbwidth(pa)+4pt) shifted center pa ;
  pb := fullcircle xsized (bbwidth(pb)+4pt) shifted center pb ;
  if na = nb :
    pab := center pa -- center pb ;
    pab := pab cutbefore (pab intersectionpoint pa) ;
    pab := pab cutafter  (pab intersectionpoint pb) ;
    pickup pencircle scaled 1pt ;
    draw pab withcolor .625yellow ;
    positioninregion ;
  fi ;
\stopMPpositiongraphic
\startpositionoverlay{foregraphics}
  \setMPpositiongraphic{G-1}{mypos:line}{to=G-2}
\stoppositionoverlay

First we have defined an \hpos {G-1} {\strut overlay}.

\stoptext
