\defineMPinstance
  [solvers]
  [format=metafun,
   extensions=yes,
   initializations=yes]

\startMPdefinitions{solvers}
  def draw_problem (expr p, q, r, s, show_lables)=
  begingroup ; save x, y, a, b, c, d, e, f, g, h ;
  z11=z42=p ; z21=z12=q ; z31=z22=r ; z41=z32=s ;
  a=x12-x11 ; b=y12-y11 ; c=x22-x21 ; d=y22-y21 ;
  e=x32-x31 ; f=y32-y31 ; g=x42-x41 ; h=y42-y41 ;
  z11=(x11, y11)              ; z12=(x12, y12) ;
  z13=(x12-b, y12+a)      ; z14=(x11-b, y11+a) ;
  z21=(x21, y21)              ; z22= (x22, y22);
  z23=(x22-s,y22+c)        ; z24=(x21-d, y21+c) ;
  z31=(x31, y31)              ; z32=(x32, y32) ;
  z33=(x32-f, y32+e)       ; z34=(x31-f, y31+e);
  z41=(x41, y41)              ; z42=(x42, y42) ;
  z43=(x42-h,y42+g)       ; z44=(x41-h,y41+g) ;
  pickup pencircle scaled .5pt ;
  draw z11--z12--z13--z14--cycle ; draw z11--z13 ; draw z12--z14 ;
  draw z21--z22--z23--z24--cycle ; draw z21—z23 ; draw z22—z24 ; 
  draw z31--z32--z33--z34--cycle ; draw z31—z33 ; draw z32—z34 ;
  draw z41--z42--z43--z44--cycle ; draw z41—z43 ; draw z42—z44 ; 
  z1=0.5[z11,z13] ; z2=0.5[z21,z23] ;
  z3=0.5[z31,z33] ; z4=0.5[z41,z43] ;
  draw z1--z3 dashed evenly ; draw z2--z4 dashed evenly ;
  z0=whatever[z1,z3]=whatever[z2,z4] ;
  mark_rt_angle (z1,z0,z2);
  if show_labels>0:
  draw_problem_labels ;
  fi;
  endgroup ;
  enddef ;
\stopMPdefinitions

\starttext
\placefigure
[here][fig:problem]
{The problem.}
{\scale
[width=\textwidth]
{\useMPgraphic{solvers::one}{i=0.6,j=1.0,s=1}}}
\stoptext
