It is a MetaFun macro in mp-tool, afaik.
The idea of filling a path is sometimes clipping to a path. Here is a way to do your task with (almost) only MetaPost:
\startMPpage[offset=2mm]
path p, q ;
p := unitsquare scaled 4cm ;
z1 = point 3.6 of p ;
q := z1 -- urcorner p -- lrcorner p -- llcorner p -- cycle;
for i = 8 step -.5 until 0:
draw (i,0)*cm -- (i-4,4)*cm withpen pencircle scaled 2pt withcolor blue;
endfor;
clip currentpicture to q;
draw p ; draw q ;
label.llft("B", llcorner p) ;
label.lrt ("C", lrcorner p) ;
label.ulft("A", ulcorner p) ;
label.urt ("D", urcorner p) ;
label.lft ("M", z1) ;
\stopMPpage
…just in case it helps to clarify.