ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Shading to transparent using withshademethod
@ 2016-01-27 21:05 Marco Patzer
  2016-01-28  8:43 ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Marco Patzer @ 2016-01-27 21:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

some months ago the withshading, withfromshadecolor etc. have apparently been
replaced by the more general withshademethod, withshadevector,
withshadecolors, etc. methods.

I have issues converting the old withshading code to the withshademethod
version. The old code had no problems shading to transparent:

\definecolor [trans] [a=multiply, t=.5, s=.5]
\starttext
\startMPcode
  path p; p:=fullsquare xyscaled (8cm, 8cm);
  fill p
    withshading("linear", ulcorner p, llcorner p)
    withfromshadecolor \MPcolor{black}
    withtoshadecolor   \MPcolor{trans};
\stopMPcode
\stoptext

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?

Marco
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-27 21:05 Shading to transparent using withshademethod Marco Patzer
@ 2016-01-28  8:43 ` Hans Hagen
  2016-01-28 10:45   ` Marco Patzer
  2016-01-28 11:29   ` Hans Hagen
  0 siblings, 2 replies; 12+ messages in thread
From: Hans Hagen @ 2016-01-28  8:43 UTC (permalink / raw)
  To: ntg-context

On 1/27/2016 10:05 PM, Marco Patzer wrote:
> Hi,
>
> some months ago the withshading, withfromshadecolor etc. have apparently been
> replaced by the more general withshademethod, withshadevector,
> withshadecolors, etc. methods.
>
> I have issues converting the old withshading code to the withshademethod
> version. The old code had no problems shading to transparent:
>
> \definecolor [trans] [a=multiply, t=.5, s=.5]
> \starttext
> \startMPcode
>    path p; p:=fullsquare xyscaled (8cm, 8cm);
>    fill p
>      withshading("linear", ulcorner p, llcorner p)
>      withfromshadecolor \MPcolor{black}
>      withtoshadecolor   \MPcolor{trans};
> \stopMPcode
> \stoptext
>
> 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)


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


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28  8:43 ` Hans Hagen
@ 2016-01-28 10:45   ` Marco Patzer
  2016-01-28 11:33     ` Hans Hagen
  2016-01-28 11:29   ` Hans Hagen
  1 sibling, 1 reply; 12+ messages in thread
From: Marco Patzer @ 2016-01-28 10:45 UTC (permalink / raw)
  To: ntg-context

On Thu, 28 Jan 2016 09:43:24 +0100
Hans Hagen <pragma@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
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28  8:43 ` Hans Hagen
  2016-01-28 10:45   ` Marco Patzer
@ 2016-01-28 11:29   ` Hans Hagen
  2016-01-28 13:02     ` Marco Patzer
  1 sibling, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2016-01-28 11:29 UTC (permalink / raw)
  To: ntg-context

On 1/28/2016 9:43 AM, Hans Hagen wrote:
> On 1/27/2016 10:05 PM, Marco Patzer wrote:
>> Hi,
>>
>> some months ago the withshading, withfromshadecolor etc. have
>> apparently been
>> replaced by the more general withshademethod, withshadevector,
>> withshadecolors, etc. methods.
>>
>> I have issues converting the old withshading code to the withshademethod
>> version. The old code had no problems shading to transparent:
>>
>> \definecolor [trans] [a=multiply, t=.5, s=.5]
>> \starttext
>> \startMPcode
>>    path p; p:=fullsquare xyscaled (8cm, 8cm);
>>    fill p
>>      withshading("linear", ulcorner p, llcorner p)
>>      withfromshadecolor \MPcolor{black}
>>      withtoshadecolor   \MPcolor{trans};
>> \stopMPcode
>> \stoptext
>>
>> 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)

next beta

\definecolor [trans] [a=multiply, t=.5, g=.5]

\startMPpage
     fill fullcircle scaled 12cm withcolor \MPcoloronly{trans};
     fill fullcircle scaled 10cm withcolor \MPcolor{trans};

     fill fullsquare xyscaled (15cm, 15cm)
       withshademethod "linear"
       withshadevector (0,1)
       withshadecolors (red,\MPcoloronly{trans})
       withtransparency \MPtransparency{trans}
     ;

\stopMPpage




-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 10:45   ` Marco Patzer
@ 2016-01-28 11:33     ` Hans Hagen
  2016-01-28 12:53       ` Marco Patzer
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2016-01-28 11:33 UTC (permalink / raw)
  To: ntg-context

On 1/28/2016 11:45 AM, Marco Patzer wrote:
> On Thu, 28 Jan 2016 09:43:24 +0100
> Hans Hagen <pragma@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?

that isn't how shading works, it's a vector from one color to the other 
(same color space eventually) and transparency is a property of the whole

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

it's already hard enough to have what we have now (tex and mp are 
different species)


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 11:33     ` Hans Hagen
@ 2016-01-28 12:53       ` Marco Patzer
  2016-01-28 13:45         ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Marco Patzer @ 2016-01-28 12:53 UTC (permalink / raw)
  To: ntg-context

On Thu, 28 Jan 2016 12:33:39 +0100
Hans Hagen <pragma@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'

> it's a vector from one color to the
> other (same color space eventually) and transparency is a property of
> the whole

That's how the new mechanism works, apparently. But transparency can
AFAIK also be a property of the colour. So transparency is a vector
from one colour to the other, each possibly being partly or entirely
transparent.

But as I don't understand the inner internals, I believe there's a
good reason this has been changed.

Marco
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 11:29   ` Hans Hagen
@ 2016-01-28 13:02     ` Marco Patzer
  2016-01-28 15:16       ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Marco Patzer @ 2016-01-28 13:02 UTC (permalink / raw)
  To: ntg-context

On Thu, 28 Jan 2016 12:29:46 +0100
Hans Hagen <pragma@wxs.nl> wrote:

> >> How to make transparent shadings work with the new mechanism?  
> >
> >        withtransparency (1,.5)  
> 
> next beta
> 
> \definecolor [trans] [a=multiply, t=.5, g=.5]
> 
> \startMPpage
>      fill fullcircle scaled 12cm withcolor \MPcoloronly{trans};
>      fill fullcircle scaled 10cm withcolor \MPcolor{trans};
> 
>      fill fullsquare xyscaled (15cm, 15cm)
>        withshademethod "linear"
>        withshadevector (0,1)
>        withshadecolors (red,\MPcoloronly{trans})
>        withtransparency \MPtransparency{trans}
>      ;
> 
> \stopMPpage

I believe the \MPcoloronly and \MPtransparency macros split up the
\MPcolor in it's colour and transparency parts.

This doesn't really provide a solution to the initial problem as I
understand. Rather it seems to be a more robust way to use
transparency and prevent choking on colours that might contain
transparent parts.

I will shade to the background colour then, which is not that clean
but works as well. Anyway, thanks for the quick answer and the
clarification.

Marco
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 12:53       ` Marco Patzer
@ 2016-01-28 13:45         ` Hans Hagen
  2016-01-28 14:34           ` Marco Patzer
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2016-01-28 13:45 UTC (permalink / raw)
  To: ntg-context

On 1/28/2016 1:53 PM, Marco Patzer wrote:
> On Thu, 28 Jan 2016 12:33:39 +0100
> Hans Hagen <pragma@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? a shade goes from one color to another; transparency is 
not part of that but applied to the whole (transparency is kind of 
independent of color and in context also only coupled in definition not 
in implementation)

>> it's a vector from one color to the
>> other (same color space eventually) and transparency is a property of
>> the whole
>
> That's how the new mechanism works, apparently. But transparency can
> AFAIK also be a property of the colour. So transparency is a vector
> from one colour to the other, each possibly being partly or entirely
> transparent.

no, it's independent ... and in shades one talks of color spaces (need 
to be the same too) so in context we even need to make sure an rgb to 
cmyk shade goes well

> But as I don't understand the inner internals, I believe there's a
> good reason this has been changed.

cleaner

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 13:45         ` Hans Hagen
@ 2016-01-28 14:34           ` Marco Patzer
  2016-01-28 17:26             ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Marco Patzer @ 2016-01-28 14:34 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 899 bytes --]

On Thu, 28 Jan 2016 14:45:13 +0100
Hans Hagen <pragma@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@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.

Marco

[-- Attachment #2: t.mkvi --]
[-- Type: application/octet-stream, Size: 476 bytes --]

\startbuffer
  \definecolor [trans] [a=multiply, t=1, s=1]
  \setupbackgrounds [page] [background=color, backgroundcolor=lightgray]
  \starttext
    \contextversion\crlf
    \startMPcode
      path p; p:=fullsquare xyscaled (12cm, 12cm);
      fill p
        withshading("linear", ulcorner p, llcorner p)
        withfromshadecolor \MPcolor{black}
        withtoshadecolor \MPcolor{trans};
    \stopMPcode
  \stoptext
\stopbuffer

\starttext
  \typebuffer\getbuffer
\stoptext

[-- Attachment #3: t.pdf --]
[-- Type: application/pdf, Size: 10735 bytes --]

[-- Attachment #4: 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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 13:02     ` Marco Patzer
@ 2016-01-28 15:16       ` Hans Hagen
  0 siblings, 0 replies; 12+ messages in thread
From: Hans Hagen @ 2016-01-28 15:16 UTC (permalink / raw)
  To: ntg-context

On 1/28/2016 2:02 PM, Marco Patzer wrote:
> On Thu, 28 Jan 2016 12:29:46 +0100
> Hans Hagen <pragma@wxs.nl> wrote:
>
>>>> How to make transparent shadings work with the new mechanism?
>>>
>>>         withtransparency (1,.5)
>>
>> next beta
>>
>> \definecolor [trans] [a=multiply, t=.5, g=.5]
>>
>> \startMPpage
>>       fill fullcircle scaled 12cm withcolor \MPcoloronly{trans};
>>       fill fullcircle scaled 10cm withcolor \MPcolor{trans};
>>
>>       fill fullsquare xyscaled (15cm, 15cm)
>>         withshademethod "linear"
>>         withshadevector (0,1)
>>         withshadecolors (red,\MPcoloronly{trans})
>>         withtransparency \MPtransparency{trans}
>>       ;
>>
>> \stopMPpage
>
> I believe the \MPcoloronly and \MPtransparency macros split up the
> \MPcolor in it's colour and transparency parts.
>
> This doesn't really provide a solution to the initial problem as I
> understand. Rather it seems to be a more robust way to use
> transparency and prevent choking on colours that might contain
> transparent parts.

In the old method we used special mp colors to store all kind of things 
which wasn't 100% robust either (because some colors were not possible 
then). Even then internally color and transparency had to be split in 
mp. The new syntax for shading is extensible.

You really don't want to know how extensions like shading and tex text 
and ... were implemented in mkii metapost.

> I will shade to the background colour then, which is not that clean
> but works as well. Anyway, thanks for the quick answer and the
> clarification.

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 14:34           ` Marco Patzer
@ 2016-01-28 17:26             ` Hans Hagen
  2016-01-28 18:09               ` Marco Patzer
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2016-01-28 17:26 UTC (permalink / raw)
  To: ntg-context

On 1/28/2016 3:34 PM, Marco Patzer wrote:
> On Thu, 28 Jan 2016 14:45:13 +0100
> Hans Hagen <pragma@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@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

\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;
      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}
      ;
     \stopMPcode
   \stoptext
\stopbuffer

\starttext
   \typebuffer\getbuffer
\stoptext



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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] 12+ messages in thread

* Re: Shading to transparent using withshademethod
  2016-01-28 17:26             ` Hans Hagen
@ 2016-01-28 18:09               ` Marco Patzer
  0 siblings, 0 replies; 12+ messages in thread
From: Marco Patzer @ 2016-01-28 18:09 UTC (permalink / raw)
  To: ntg-context

On Thu, 28 Jan 2016 18:26:28 +0100
Hans Hagen <pragma@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@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@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
___________________________________________________________________________________
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] 12+ messages in thread

end of thread, other threads:[~2016-01-28 18:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27 21:05 Shading to transparent using withshademethod Marco Patzer
2016-01-28  8:43 ` Hans Hagen
2016-01-28 10:45   ` Marco Patzer
2016-01-28 11:33     ` Hans Hagen
2016-01-28 12:53       ` Marco Patzer
2016-01-28 13:45         ` Hans Hagen
2016-01-28 14:34           ` Marco Patzer
2016-01-28 17:26             ` Hans Hagen
2016-01-28 18:09               ` Marco Patzer
2016-01-28 11:29   ` Hans Hagen
2016-01-28 13:02     ` Marco Patzer
2016-01-28 15:16       ` Hans Hagen

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