[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



def SoundEnergy =

 path pr ; pr := unitsquare xscaled .3cm yscaled 2cm ;

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

 clip currentpicture to

 draw (0,0)--(0,2cm)--(2cm,2cm)--(3cm,1cm)--(2cm,0)--cycle withcolor
 addto finalpicture also currentpicture shifted(avanco*3.5cm,0) ;
 currentpicture := nullpicture ; avanco := avanco+1 ;



picture finalpicture ; finalpicture := nullpicture ;
numeric avanco ; avanco := 0 ; bboxmargin := 0pt ;

%% first call is OK

%% second call loss the gradient

currentpicture := finalpicture ;


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