[NTG-context] Shading to transparent using withshademethod

Marco Patzer lists at homerow.info
Thu Jan 28 11:45:53 CET 2016


On Thu, 28 Jan 2016 09:43:24 +0100
Hans Hagen <pragma at wxs.nl> wrote:

> On 1/27/2016 10:05 PM, Marco Patzer wrote:
> > The new code appears to work in general, but only if no shading to
> > transparent is being used:
> >
> > \definecolor [trans] [a=multiply, t=.5, s=.5]
> > \starttext
> >    \startMPcode
> >      % works
> >      fill fullcircle scaled 10cm withcolor \MPcolor{trans};
> >
> >      fill fullsquare xyscaled (15cm, 15cm)
> >        withshademethod "linear"
> >        withshadevector (0,1)
> >        % works
> >        withshadecolors (red,\MPcolor{blue})
> >        % fails
> >        %% withshadecolors (red,\MPcolor{trans})
> >        ;
> >    \stopMPcode
> > \stoptext
> >
> > How to make transparent shadings work with the new mechanism?  
> 
>        withtransparency (1,.5)

However, this makes the entire shade transparent. How to shade from
one colour to transparent using withtransparency to achieve an
effect like in the example below?

\definecolor      [trans] [a=multiply, t=0]
\setupbackgrounds [page]  [background=color, backgroundcolor=lightgray]

\starttext
  \startMPcode
  fill fullsquare xyscaled (15cm, 15cm)
    withshademethod "linear"
    withshadevector (0, 1)
    %% colour doens't match
    %% withshadecolors (red, lightgray)
    %% output is ok with \MPcolor
    withshadecolors (red, \MPcolor{lightgray})
    %% ??
    %% withtransparency (1, .5)
    ;
  \stopMPcode
\stoptext

Furthermore, why do the tex and MP colours differ? Wouldn't it make
sense to use the same colour definitions? Or was that intentional?

Marco


More information about the ntg-context mailing list