ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Strange output from linear_shade (METAPOST)
@ 2014-02-15  0:15 DesdeChaves
  0 siblings, 0 replies; only message in thread
From: DesdeChaves @ 2014-02-15  0:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1198 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 1832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-15  0:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15  0:15 Strange output from linear_shade (METAPOST) DesdeChaves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).