Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

On 1/28/2016 2:02 PM, Marco Patzer wrote:

On Thu, 28 Jan 2016 12:29:46 +0100
Hans Hagen  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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

On 1/28/2016 3:34 PM, Marco Patzer wrote:

On Thu, 28 Jan 2016 14:45:13 +0100
Hans Hagen  wrote:


On 1/28/2016 1:53 PM, Marco Patzer wrote:

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

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Marco Patzer
On Thu, 28 Jan 2016 18:26:28 +0100
Hans Hagen  wrote:

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

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Marco Patzer
On Thu, 28 Jan 2016 12:33:39 +0100
Hans Hagen  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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Marco Patzer
On Thu, 28 Jan 2016 12:29:46 +0100
Hans Hagen  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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Marco Patzer
On Thu, 28 Jan 2016 09:43:24 +0100
Hans Hagen  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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

On 1/28/2016 11:45 AM, Marco Patzer wrote:

On Thu, 28 Jan 2016 09:43:24 +0100
Hans Hagen  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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Marco Patzer
On Thu, 28 Jan 2016 14:45:13 +0100
Hans Hagen  wrote:

> On 1/28/2016 1:53 PM, Marco Patzer wrote:
> > On Thu, 28 Jan 2016 12:33:39 +0100
> > Hans Hagen  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


t.mkvi
Description: Binary data


t.pdf
Description: Adobe PDF document
___
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
___

Re: [NTG-context] Shading to transparent using withshademethod

2016-01-28 Thread Hans Hagen

On 1/28/2016 1:53 PM, Marco Patzer wrote:

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

[NTG-context] Shading to transparent using withshademethod

2016-01-27 Thread Marco Patzer
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
___