[NTG-context] Shading and transparency

Hans Hagen j.hagen at xs4all.nl
Thu Jul 12 22:59:05 CEST 2018


On 7/12/2018 10:08 PM, Marco Patzer wrote:
> On Thu, 12 Jul 2018 11:21:45 +0200
> Hans Hagen <j.hagen at xs4all.nl> wrote:
> 
>>> For the old implementation (pre 2016-ish) I had a working solution
>>> because shading to transparent colours just worked (at least in my
>>> case of a simple transparent shade, nothing fancy), but not so any
>>> longer. With the new implementation I couldn't get it working. But
>>> we discussed that at some point in the past. I believe the gist of
>>> it was “shade-to-transparent is gone”.
>>
>> i'm not ssure what shade to transparency means
> 
> I mean a shade from a colour (e.g. black) to transparent. For
> instance this used to work pre 2016:
> 
> \setupbackgrounds [page] [background=color, backgroundcolor=lightgray]
> \definecolor [trans] [a=multiply, t=1, s=1]
> \starttext
> \startMPcode
>    path p; p:=fullsquare xyscaled (5cm, 5cm);
>    fill p
>      withshading("linear", ulcorner p, llcorner p)
>      withfromshadecolor \MPcolor{white}
>      withtoshadecolor   \MPcolor{trans};
> \stopMPcode
> \stoptext
> 
> The shade goes from white to transparent (here lightgray, that's the
> page colour). I assume you have an older context laying around to
> run the example above.
> 
>> ... shades can be transparent currently
> 
> Yes, but the *whole* shade is made transparent. Currently I don't
> know a way to shade from e.g. black to transparent (no colour). The
> colour involved in the shading can't have transparency, or if they
> do one has to use \MPcoloronly to get rid of the transparency part.

hm, I'm puzzled as a shade doesn't go between colors + transparent but 
from one color to another (in the same color space) and transparency is 
just a different mechanism

maybe it was some side effect of chosen values / vectors that gave the 
combined impression (which is why i want to see the pdf made by context 
that you use as reference)

anyway, it helps to be in the same color space

\setupbackgrounds [page] [background=color, backgroundcolor=lightgray]

\starttext

\startuseMPgraphic{test}
     graycolor white; white := 1 ;
     fill OverlayBox
         withshademethod "linear"
         withshadedirection shadedup
         withshadefactor 1.5
         withshadecolors (.85white,white)
       % withtransparency (multiplytransparent,.7)
         withtransparency (normaltransparent,.7)
\stopuseMPgraphic

\defineoverlay[test][\useMPgraphic{test}]

\framed
   [align=middle,background={foreground,test}]
   {\samplefile{sapolsky}}

\stoptext


> So the above old syntax roughly translated to the current
> implementation:
> 
> \setupbackgrounds [page] [background=color, backgroundcolor=lightgray]
> \definecolor [trans] [a=multiply, t=1, s=1]
> \starttext
> \startMPcode
>    path p; p:=fullsquare xyscaled (5cm, 5cm);
>      fill p
>        withshademethod "linear"
>        withshadevector (3, 0)
>        %% since "trans" contains transparency, one has to use
> \MPcoloronly withshadecolors (white, \MPcoloronly{trans})
>        withtransparency (.5, .5)
>        %% withtransparency \MPtransparency{trans}
>        ;
>    \stopMPcode
> \stoptext
> 
>> .. so how did that old file (uncompressed pdf) look like then
> 
> Just run the first example with an old context version. The file
> gradient-t from my last mail was created using inkscape as I don't
> want a single project to depend on two different context versions.
you're kidding ... i have no old context on my machine

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the ntg-context mailing list