[NTG-context] Shading to transparent using withshademethod

Marco Patzer lists at homerow.info
Thu Jan 28 19:09:50 CET 2016


On Thu, 28 Jan 2016 18:26:28 +0100
Hans Hagen <pragma at wxs.nl> wrote:

> On 1/28/2016 3:34 PM, Marco Patzer wrote:
> > On Thu, 28 Jan 2016 14:45:13 +0100
> > Hans Hagen <pragma at wxs.nl> wrote:
> >  
> >> On 1/28/2016 1:53 PM, Marco Patzer wrote:  
> >>> On Thu, 28 Jan 2016 12:33:39 +0100
> >>> Hans Hagen <pragma at wxs.nl> wrote:
> >>>  
> >>>>>>> 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?  
> >>>>
> >>>> that isn't how shading works,  
> >>>
> >>> …any longer. I just confirmed that it used to work on an older
> >>> installation. Just sayin'  
> >>
> >> are you sure?  
> >
> > See the attached example. The shade seems to go from black to fully
> > transparent. So regardless of the background colour the shade looks
> > fine. I can't replicate this with the new mechanism.  
> 
> a matter of choosing the colors

Indeed, if you choose the colours wisely you don't necessarily need
transparency (at least in my use case).

> \unprotect
> 
> \def\MPcoloronly#1%
>    {\clf_mpcolor
>       \attribute\colormodelattribute
>       \colo_helpers_inherited_current_ca{#1} %
>       \zerocount}
> 
> \def\MPtransparency#1%
>    {\clf_mpcolor
>       \zerocount
>       \zerocount
>       \colo_helpers_inherited_current_ta{#1} }
> 
> \protect
> 
> \startbuffer
>    \definecolor[tex:bg][s=.85]
>    \definecolor[mp:fg] [s=.85,t=1,a=1]
>    \setupbackgrounds [page] [background=color,backgroundcolor=tex:bg]
>    \starttext
>      \contextversion\crlf
>      \startMPcode
>     % lightgray = 0.85white;
                     ^^^ That looks more like Tex's lightgray

>       fill fullsquare xyscaled (12cm, 12cm)
>         withshademethod "linear"
>         withshadevector (-1,0)
>       % withshadecolors (black,lightgray)
>       % withtransparency (1,1)
>         withshadecolors (black,\MPcoloronly{mp:fg})
>         withtransparency \MPtransparencyonly{mp:fg}
                                         ^^^^^  Typo or new feature?
                                         looks like \MPtransparency
                                         should be sufficient
>       ;
>      \stopMPcode
>    \stoptext
> \stopbuffer
> 
> \starttext
>    \typebuffer\getbuffer
> \stoptext

I'll play with the code in the new beta.

Marco


More information about the ntg-context mailing list