outputtemplate := "%j-%c.mps";
prologues := 1;

numeric w, h, dw, steps;
w := 10cm;% shading width
h := 1cm;% shading height
steps := 64;% shading steps
dw := w/steps;% shading step width

def fillbox=fill (unitsquare xscaled dw yscaled h) enddef;

%%% colA : start colour
%%% colB : end colour
%%% offset : offset
def proof(expr colA, colB, offset)=
  for i=0 upto steps:
    fillbox shifted (dw*i,0) shifted offset withcolor (i/steps)[colA,colB];
  endfor
enddef;

beginfig(1);
  % CMYK: white to black
  proof((0,0,0,0), (0,0,0,1), origin);
  % RGB: black only
  proof((0,0,0), (0,0,0), (0,-h));
  % CMYK: black to registration black
  proof((0,0,0,1), (1,1,1,1), (0,-2h));
endfig;
end
