[NTG-context] Strange output from linear_shade (METAPOST)

DesdeChaves desdechaves at gmail.com
Sat Feb 15 01:15:15 CET 2014


I need to create some graphics to teach energy. One of the illustrations is
about the sound energy that I represent using linear_shade function. In the
following example the first illustration is represented correctly, but the
second call of the function SoundEnergy implies the loss of gradient. What
am I doing wrong?

Thanks in advance

Jorge

\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 ;

%% first call is OK
SoundEnergy;

%% second call loss the gradient
SoundEnergy;


currentpicture := finalpicture ;

\stopMPcode


\stoptext
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20140215/0180b4f2/attachment.html>


More information about the ntg-context mailing list