What is wrong with my code? The second call of SoundEnergy lost the black/white gradient.
\startMPinclusions
def SoundEnergy =
path pr ; pr := unitsquare xscaled .3cm yscaled 2cm ;
currentpicture:=nullpicture;
for i=0 step 2 until 10:
linear_shade(pr shifted (i*.3cm,0),0,white,black);
linear_shade(pr shifted ((i+1)*.3cm,0),0,black,white);
endfor;
clip currentpicture to (0,0)--(0,2cm)--(2cm,2cm)--(3cm,1cm)--(2cm,0)--cycle;
draw (0,0)--(0,2cm)--(2cm,2cm)--(3cm,1cm)--(2cm,0)--cycle withcolor .625red;
addto finalpicture also currentpicture shifted(avanco*3.5cm,0) ;
currentpicture := nullpicture ; avanco := avanco+1 ;
enddef;
\stopMPinclusions
\starttext
\startMPcode
picture finalpicture ; finalpicture := nullpicture ;
numeric avanco ; avanco := 0 ; bboxmargin := 0pt ;
SoundEnergy;SoundEnergy;
currentpicture := finalpicture ;
\stopMPcode
\stoptext


addtoprocedures and the like, but to act like the non-problematic example on the top of page 187 (shifting the shaded figure while staying inside the same picture). – Franck Pastor Feb 15 '14 at 20:16