ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: colors in pgf within context
       [not found] <m2bq6dvj38.fsf@DNab422469.Stanford.EDU>
@ 2008-02-19  2:43 ` Aditya Mahajan
  2008-02-19  3:33   ` Jesse Alama
  0 siblings, 1 reply; 11+ messages in thread
From: Aditya Mahajan @ 2008-02-19  2:43 UTC (permalink / raw)
  To: Jesse Alama; +Cc: mailing list for ConTeXt users

Hi Jesse,

I am CCing to the context list also.

On Mon, 18 Feb 2008, Jesse Alama wrote:

> Hi Aditya,
>
> I recently came across a thread on the PGF users mailing list in which
> you mention some problems with ConTeXt, PGF and colors.  For example:
>
>  http://article.gmane.org/gmane.comp.tex.pgf.user/38
>
> Have these issues beein resolved for your?  I just downloaded PFG 1.18
> from the modules part of the contextgarden, installed it, and, when
> trying to compile the following example PGF code
>
>  \starttikzpicture[scale=3]
>    \clip (-2,-0.2) rectangle (2,0.8);
>    \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
>    \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc
>    (0:30:3mm) -- cycle;
>    \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
>    \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
>    \draw (0,0) circle (1cm);
>
>    \draw[very thick,red]
>      (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis);
>    \draw[very thick,blue]
>      (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
>    \draw[very thick,orange]  (1,0) -- node [right=1pt,fill=white]
>      {$\displaystyle \tan \alpha \color{black}=
>        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$}
>      (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
>
>    \draw (0,0) -- (t);
>    \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
>    \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {$\xtext$};
>    \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
>    \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$};
>  \stoptikzpicture
>
> (which is taken from the PGF manual), I get
>
>  ! Use of \color doesn't match its definition.
>  \tikz@temp ...{$\displaystyle \tan \alpha \color {
>                                                    black}= \frac {{\color {re...
>
>  \tikz@invoke@collected@onpath ...mmand \tikz@temp
>                                                    \pgf@stop \tikz@node@is@a@...
>
>  \tikz@scan@next@command ...nvoke@collected@onpath
>                                                    \fi \afterassignment \tikz...
>  l.86 ...(intersection of 0,0--30:1cm and 1,0--1,1)
>                                                     coordinate (t);
>  ?
>
> The problem does seem to be that PGF and ConTeXt both want to define
> \color.
>
> Any ideas how to get around the problem?  As it stands, it seems safe to
> say that, if colors don't work, then PGF is quite crippled in ConTeXt.

No, the reason for the error is more subtle. PGF does try its best to work 
with ConTeXt colors. However, there is a difference between latex and 
context color usage, that gives rise to the error. The culprit in this 
case is:

{$\displaystyle \tan \alpha \color{black}=
        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$}

Try this in a standalong context file (no pgf) and you will get an error. 
First you need to change \color{black} to \color[black]. Even then you 
will get an error. You need to use

{$\displaystyle \tan \alpha {\color[black]=
        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$}


(Notice the {...} around \color[black]). Then everything works fine. Here 
is a working example (latest pgf from cvs, but should also work with 
1.18).

\usemodule[tikz]
\setupcolors[state=start]

\starttext

\starttikzpicture[scale=3]
   \clip (-2,-0.2) rectangle (2,0.8);
   \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
   \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc
   (0:30:3mm) -- cycle;
   \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
   \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
   \draw (0,0) circle (1cm);
   \draw[very thick,red]
     (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x 
axis);
   \draw[very thick,blue]
     (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} 
(0,0);
   \draw[very thick,orange]  (1,0) -- node [right=1pt,fill=white]
     {$\displaystyle \tan \alpha {\color[black]=
       \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$}
     (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
   \draw (0,0) -- (t);
   \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
   \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] 
{$\xtext$};
   \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
   \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] 
{$\ytext$};
\stoptikzpicture
\stoptext

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  2:43 ` colors in pgf within context Aditya Mahajan
@ 2008-02-19  3:33   ` Jesse Alama
  2008-02-19  3:47     ` Aditya Mahajan
  2008-02-19  8:50     ` Hans Hagen
  0 siblings, 2 replies; 11+ messages in thread
From: Jesse Alama @ 2008-02-19  3:33 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

Hi Aditya,

Thanks for the help -- I think I now see why there is such trouble with
colors in pgf and context.  It looks like one can systematically
transform LaTeX-like PGF examples of \color into ConTeXt examples.

The reason why this came up is that I'm trying to go through Till
Tantau's "Example for Karl's Students" tutorial in the PGF/TikZ manual.
Has anyone managed to ConTeXt-ify that example?  The closest that I've come is

  \usemodule[tikz]
  \setupcolors[state=start]
  \starttext
  \starttikzpicture
    [scale=3,
     line cap=thin,
     %Styles
     axes/.style=, 
     important line/.style={very thick}, 
     information text/.style={rounded corners,fill=red!10,inner sep=1ex}] 
  % Local definitions 
  \def\costhirty{0.8660256} 
  % The graphic 
  \draw[help lines,step=0.5cm] (-1.4,-1.4) grid (1.4,1.4); 
  \draw (0,0) circle (1cm); 
  \startscope[axes] 
  \draw[->] (-1.5,0) -- (1.5,0) node[right] {$x$} coordinate(x axis); 
  \draw[->] (0,-1.5) -- (0,1.5) node[above] {$y$} coordinate(y axis); 
  \foreach \x/\xtext in {-1, -.5/-\frac{1}{2}, 1} 
  \draw[xshift=\x cm] (0pt,1pt) -- (0pt,-1pt) node[below,fill=white] {$\xtext$}; 
  \foreach \y/\ytext in {-1, -.5/-\frac{1}{2}, .5/\frac{1}{2}, 1} 
  \draw[yshift=\y cm] (1pt,0pt) -- (-1pt,0pt) node[left,fill=white] {$\ytext$}; 
  \stopscope
  \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0pt) arc(0:30:3mm); 
  \draw (15:2mm) node[green!50!black] {$\alpha$}; 
  \draw[important line,red] 
  (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis); 
  
  \draw[important line,orange!80!black] (1,0) -- node[right=1pt,fill=white] { 
  $\displaystyle \tan \alpha \color[black]{=}
  \frac{\color[red]{\sin \alpha}}{\color[blue]{\cos \alpha}}$} 
  (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t); 
  \draw (0,0) -- (t); 
  \draw[xshift=1.85cm] 
  node[right,text width=6cm,information text] 
  { 
  The \color[green!50!black]{angle $\alpha$} is $30^\circ$ in the 
  example ($\pi/6$ in radians). The \color[red]{sine of 
  $\alpha$}, which is the height of the red line, is 
  \startformula
  \color[red]{\sin \alpha} = 1/2.
  \stopformula
  By the Theorem of Pythagoras ... 
  }; 
  \stoptikzpicture
  \stoptext

The example features some \definecolor's which I just did away with
(sadly) by simply substituting their defining values for their
occurences.  (This is unfortunate, but perhaps necessary until some
other mechanism is produced.)  The problem is that the text box to the
right of the picture is supposed to be colored, and with rounded
corners.  But the box is missing.  Look at p. 20 of

  http://altermundus.com/downloads/pgfmanual_cvs.pdf
  
to see what I mean.  Also, the phrase "angle $\alpha$" is supposed to be
in a kind of green, but that's not working either.  What might be
happening?

Thanks,

Jesse

Aditya Mahajan <adityam@umich.edu> writes:

> I am CCing to the context list also.
>
> On Mon, 18 Feb 2008, Jesse Alama wrote:
>
>> Hi Aditya,
>>
>> I recently came across a thread on the PGF users mailing list in which
>> you mention some problems with ConTeXt, PGF and colors.  For example:
>>
>>  http://article.gmane.org/gmane.comp.tex.pgf.user/38
>>
>> Have these issues beein resolved for your?  I just downloaded PFG 1.18
>> from the modules part of the contextgarden, installed it, and, when
>> trying to compile the following example PGF code
>>
>>  \starttikzpicture[scale=3]
>>    \clip (-2,-0.2) rectangle (2,0.8);
>>    \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
>>    \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc
>>    (0:30:3mm) -- cycle;
>>    \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
>>    \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
>>    \draw (0,0) circle (1cm);
>>
>>    \draw[very thick,red]
>>      (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x axis);
>>    \draw[very thick,blue]
>>      (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$} (0,0);
>>    \draw[very thick,orange]  (1,0) -- node [right=1pt,fill=white]
>>      {$\displaystyle \tan \alpha \color{black}=
>>        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$}
>>      (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
>>
>>    \draw (0,0) -- (t);
>>    \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
>>    \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white] {$\xtext$};
>>    \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
>>    \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white] {$\ytext$};
>>  \stoptikzpicture
>>
>> (which is taken from the PGF manual), I get
>>
>>  ! Use of \color doesn't match its definition.
>>  \tikz@temp ...{$\displaystyle \tan \alpha \color {
>>                                                    black}= \frac {{\color {re...
>>
>>  \tikz@invoke@collected@onpath ...mmand \tikz@temp
>>                                                    \pgf@stop \tikz@node@is@a@...
>>
>>  \tikz@scan@next@command ...nvoke@collected@onpath
>>                                                    \fi \afterassignment \tikz...
>>  l.86 ...(intersection of 0,0--30:1cm and 1,0--1,1)
>>                                                     coordinate (t);
>>  ?
>>
>> The problem does seem to be that PGF and ConTeXt both want to define
>> \color.
>>
>> Any ideas how to get around the problem?  As it stands, it seems safe to
>> say that, if colors don't work, then PGF is quite crippled in ConTeXt.
>
> No, the reason for the error is more subtle. PGF does try its best to
> work with ConTeXt colors. However, there is a difference between latex
> and context color usage, that gives rise to the error. The culprit in
> this case is:
>
> {$\displaystyle \tan \alpha \color{black}=
>        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}$}
>
> Try this in a standalong context file (no pgf) and you will get an
> error. First you need to change \color{black} to \color[black]. Even
> then you will get an error. You need to use
>
> {$\displaystyle \tan \alpha {\color[black]=
>        \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$}
>
>
> (Notice the {...} around \color[black]). Then everything works
> fine. Here is a working example (latest pgf from cvs, but should also
> work with 1.18).
>
> \usemodule[tikz]
> \setupcolors[state=start]
>
> \starttext
>
> \starttikzpicture[scale=3]
>   \clip (-2,-0.2) rectangle (2,0.8);
>   \draw[step=.5cm,gray,very thin] (-1.4,-1.4) grid (1.4,1.4);
>   \filldraw[fill=green!20,draw=green!50!black] (0,0) -- (3mm,0mm) arc
>   (0:30:3mm) -- cycle;
>   \draw[->] (-1.5,0) -- (1.5,0) coordinate (x axis);
>   \draw[->] (0,-1.5) -- (0,1.5) coordinate (y axis);
>   \draw (0,0) circle (1cm);
>   \draw[very thick,red]
>     (30:1cm) -- node[left=1pt,fill=white] {$\sin \alpha$} (30:1cm |- x
> axis);
>   \draw[very thick,blue]
>     (30:1cm |- x axis) -- node[below=2pt,fill=white] {$\cos \alpha$}
> (0,0);
>   \draw[very thick,orange]  (1,0) -- node [right=1pt,fill=white]
>     {$\displaystyle \tan \alpha {\color[black]=
>       \frac{{\color[red]\sin \alpha}}{{\color[blue]\cos \alpha}}}$}
>     (intersection of 0,0--30:1cm and 1,0--1,1) coordinate (t);
>   \draw (0,0) -- (t);
>   \foreach \x/\xtext in {-1, -0.5/-\frac{1}{2}, 1}
>   \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north,fill=white]
> {$\xtext$};
>   \foreach \y/\ytext in {-1, -0.5/-\frac{1}{2}, 0.5/\frac{1}{2}, 1}
>   \draw (1pt,\y cm) -- (-1pt,\y cm) node[anchor=east,fill=white]
> {$\ytext$};
> \stoptikzpicture
> \stoptext
>
> Aditya
>

-- 
Jesse Alama (alama@stanford.edu)
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  3:33   ` Jesse Alama
@ 2008-02-19  3:47     ` Aditya Mahajan
       [not found]       ` <alpine.DEB.1.00.0802182252560.21564@nqv-yncgbc>
                         ` (2 more replies)
  2008-02-19  8:50     ` Hans Hagen
  1 sibling, 3 replies; 11+ messages in thread
From: Aditya Mahajan @ 2008-02-19  3:47 UTC (permalink / raw)
  To: Jesse Alama; +Cc: mailing list for ConTeXt users

On Mon, 18 Feb 2008, Jesse Alama wrote:

> Hi Aditya,
>
> Thanks for the help -- I think I now see why there is such trouble with
> colors in pgf and context.  It looks like one can systematically
> transform LaTeX-like PGF examples of \color into ConTeXt examples.
>
> The reason why this came up is that I'm trying to go through Till
> Tantau's "Example for Karl's Students" tutorial in the PGF/TikZ manual.
> Has anyone managed to ConTeXt-ify that example?

I did that some time back while testing tikz. I will send that file as a 
reply to this email, since I am not sure if it will go through the mailing 
list because of its size.

> The example features some \definecolor's which I just did away with
> (sadly) by simply substituting their defining values for their
> occurences.  (This is unfortunate, but perhaps necessary until some
> other mechanism is produced.)  The problem is that the text box to the
> right of the picture is supposed to be colored, and with rounded
> corners.  But the box is missing.  Look at p. 20 of

The TikZ manual make a lot of uses of the xcolor syntax (e.g. 
\color{red!20}). There is no equivalent ConTeXt syntax. You need to define 
a color, say lightred, as follows

\definecolor[lightred][r=0.2]

For tikz key-value options, pgf works behind the scene to define 
appropriate colors, so xcolor syntax works for them. So 
\fill[fillcolor=red!20] will work as expected. However, when using \color 
inside any box, you need to follow ConTeXt syntax. So \color[red!20] will 
not work, you need to define a context color and then use that.

Hope that this clarifies some things.

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
       [not found]       ` <alpine.DEB.1.00.0802182252560.21564@nqv-yncgbc>
@ 2008-02-19  4:56         ` Jesse Alama
  0 siblings, 0 replies; 11+ messages in thread
From: Jesse Alama @ 2008-02-19  4:56 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

Cool, thanks.  It looks like we'll need env-tikz.tex, too :->

Jesse

Aditya Mahajan <adityam@umich.edu> writes:

> On Mon, 18 Feb 2008, Aditya Mahajan wrote:
>
>> I did that some time back while testing tikz. I will send that file as a
>> reply to this email, since I am not sure if it will go through the mailing
>> list because of its size.
>
> The file is attached. I am sure that there are better ways to convert
> the whole thing to context, but I just followed a quick and dirty
> conversion.


-- 
Jesse Alama (alama@stanford.edu)
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  3:47     ` Aditya Mahajan
       [not found]       ` <alpine.DEB.1.00.0802182252560.21564@nqv-yncgbc>
@ 2008-02-19  8:20       ` Alan BRASLAU
  2008-02-19 16:33         ` Aditya Mahajan
  2008-02-19 17:36       ` Jesse Alama
  2 siblings, 1 reply; 11+ messages in thread
From: Alan BRASLAU @ 2008-02-19  8:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello,

Another problem with PGF+ConTeXt is the handling of cmyk colors:

\usemodule[tikz]
\setupcolors[state=start]
\definecolor[my_yellow][c=0,m=0.3,y=0.94,k=0]
\starttext
\startcolor[my_yellow]
Yellow text.
\stopcolor
\starttikzpicture
	\fill[my_yellow] (0,0) circle(1);
\stoptikzpicture
\stoptext

CMYK colors work in ConTeXt but do not get passed correctly to PGF/TikZ.
A work-around is to transform to rgb :
\definecolor[my_yellow][r=0.98,g=0.698,b=0.09] % 250,178,23 #FAB217

This seems to be a documented bug; Perhaps it will be fixed someday...

Alan

On Tuesday 19 February 2008 04:47:35 Aditya Mahajan wrote:
> On Mon, 18 Feb 2008, Jesse Alama wrote:
> > Hi Aditya,
> >
> > Thanks for the help -- I think I now see why there is such trouble with
> > colors in pgf and context.  It looks like one can systematically
> > transform LaTeX-like PGF examples of \color into ConTeXt examples.
> >
> > The reason why this came up is that I'm trying to go through Till
> > Tantau's "Example for Karl's Students" tutorial in the PGF/TikZ manual.
> > Has anyone managed to ConTeXt-ify that example?
>
> I did that some time back while testing tikz. I will send that file as a
> reply to this email, since I am not sure if it will go through the mailing
> list because of its size.
>
> > The example features some \definecolor's which I just did away with
> > (sadly) by simply substituting their defining values for their
> > occurences.  (This is unfortunate, but perhaps necessary until some
> > other mechanism is produced.)  The problem is that the text box to the
> > right of the picture is supposed to be colored, and with rounded
> > corners.  But the box is missing.  Look at p. 20 of
>
> The TikZ manual make a lot of uses of the xcolor syntax (e.g.
> \color{red!20}). There is no equivalent ConTeXt syntax. You need to define
> a color, say lightred, as follows
>
> \definecolor[lightred][r=0.2]
>
> For tikz key-value options, pgf works behind the scene to define
> appropriate colors, so xcolor syntax works for them. So
> \fill[fillcolor=red!20] will work as expected. However, when using \color
> inside any box, you need to follow ConTeXt syntax. So \color[red!20] will
> not work, you need to define a context color and then use that.
>
> Hope that this clarifies some things.
>
> Aditya
> ___________________________________________________________________________
>________ 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  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________
>________



-- 
Alan Braslau
CEA DSM-IRAMIS-SPEC
CNRS URA 2464
Orme des Merisiers
91191 Gif-sur-Yvette cedex FRANCE
tel: +33 1 69 08 73 15
fax: +33 1 69 08 87 86
mailto:alan.braslau@cea.fr

http://www-dna2006.cea.fr/

 .''`.
: :'  :
`. `'`
  `-
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  3:33   ` Jesse Alama
  2008-02-19  3:47     ` Aditya Mahajan
@ 2008-02-19  8:50     ` Hans Hagen
  1 sibling, 0 replies; 11+ messages in thread
From: Hans Hagen @ 2008-02-19  8:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Jesse Alama wrote:
> Hi Aditya,
> 
> Thanks for the help -- I think I now see why there is such trouble with
> colors in pgf and context.  It looks like one can systematically
> transform LaTeX-like PGF examples of \color into ConTeXt examples.

keep in mind that color handles sveral grouping cases:

{\somecolor whatever}

\color[somecolor]{whatever}

all use the same underlying mechanissm (and sometimes aftergroup to 
revert to the outer color; this may interfere when grouping is kind of 
unpredictable

in case of doubt: \color[name]{..} works best (explicit braces)



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | 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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  8:20       ` Alan BRASLAU
@ 2008-02-19 16:33         ` Aditya Mahajan
  0 siblings, 0 replies; 11+ messages in thread
From: Aditya Mahajan @ 2008-02-19 16:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Tue, 19 Feb 2008, Alan BRASLAU wrote:

> Hello,
>
> Another problem with PGF+ConTeXt is the handling of cmyk colors:
>
> \usemodule[tikz]
> \setupcolors[state=start]
> \definecolor[my_yellow][c=0,m=0.3,y=0.94,k=0]
> \starttext
> \startcolor[my_yellow]
> Yellow text.
> \stopcolor
> \starttikzpicture
> 	\fill[my_yellow] (0,0) circle(1);
> \stoptikzpicture
> \stoptext
>
> CMYK colors work in ConTeXt but do not get passed correctly to PGF/TikZ.
> A work-around is to transform to rgb :
> \definecolor[my_yellow][r=0.98,g=0.698,b=0.09] % 250,178,23 #FAB217
>
> This seems to be a documented bug; Perhaps it will be fixed someday...

Please report it again on the pgf mailing list. Till Tantau is making 
significant changes to pgf and I do not think it should be too difficult 
for pgf to support cmyk color model in ConTeXt.

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19  3:47     ` Aditya Mahajan
       [not found]       ` <alpine.DEB.1.00.0802182252560.21564@nqv-yncgbc>
  2008-02-19  8:20       ` Alan BRASLAU
@ 2008-02-19 17:36       ` Jesse Alama
  2008-02-19 17:57         ` Aditya Mahajan
  2 siblings, 1 reply; 11+ messages in thread
From: Jesse Alama @ 2008-02-19 17:36 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

Aditya Mahajan <adityam@umich.edu> writes:

>> The example features some \definecolor's which I just did away with
>> (sadly) by simply substituting their defining values for their
>> occurences.  (This is unfortunate, but perhaps necessary until some
>> other mechanism is produced.)  The problem is that the text box to the
>> right of the picture is supposed to be colored, and with rounded
>> corners.  But the box is missing.  Look at p. 20 of
>
> The TikZ manual make a lot of uses of the xcolor syntax
> (e.g. \color{red!20}). There is no equivalent ConTeXt syntax. You need
> to define a color, say lightred, as follows
>
> \definecolor[lightred][r=0.2]
>
> For tikz key-value options, pgf works behind the scene to define
> appropriate colors, so xcolor syntax works for them. So
> \fill[fillcolor=red!20] will work as expected. However, when using
> \color inside any box, you need to follow ConTeXt syntax. So
> \color[red!20] will not work, you need to define a context color and
> then use that.

I'm still not able to get fillcolor to work with the information box:

  \starttikzpicture[scale=4,information text/.style={fill=red}]
  \draw[xshift=1.85cm] node[right,text width=6cm,information text] 
  { 
  The \color[green]{angle $\alpha$} is
    $30^\circ$ in the example ($\pi/6$ in radians). The \color[red]{sine
      of $\alpha$}, which is the height of the red line, is
  \startformula
  \color[red]{\sin \alpha} = 1/2.
  \stopformula
  By the Theorem of Pythagoras ... 
  };

Is ConTeXt correctly parsing the key "information tex/.style"?

Jesse

-- 
Jesse Alama (alama@stanford.edu)
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19 17:36       ` Jesse Alama
@ 2008-02-19 17:57         ` Aditya Mahajan
  2008-02-19 18:30           ` Jesse Alama
  0 siblings, 1 reply; 11+ messages in thread
From: Aditya Mahajan @ 2008-02-19 17:57 UTC (permalink / raw)
  To: Jesse Alama; +Cc: mailing list for ConTeXt users

On Tue, 19 Feb 2008, Jesse Alama wrote:

> Aditya Mahajan <adityam@umich.edu> writes:
>
>>> The example features some \definecolor's which I just did away with
>>> (sadly) by simply substituting their defining values for their
>>> occurences.  (This is unfortunate, but perhaps necessary until some
>>> other mechanism is produced.)  The problem is that the text box to the
>>> right of the picture is supposed to be colored, and with rounded
>>> corners.  But the box is missing.  Look at p. 20 of
>>
>> The TikZ manual make a lot of uses of the xcolor syntax
>> (e.g. \color{red!20}). There is no equivalent ConTeXt syntax. You need
>> to define a color, say lightred, as follows
>>
>> \definecolor[lightred][r=0.2]
>>
>> For tikz key-value options, pgf works behind the scene to define
>> appropriate colors, so xcolor syntax works for them. So
>> \fill[fillcolor=red!20] will work as expected. However, when using
>> \color inside any box, you need to follow ConTeXt syntax. So
>> \color[red!20] will not work, you need to define a context color and
>> then use that.
>
> I'm still not able to get fillcolor to work with the information box:
>
>  \starttikzpicture[scale=4,information text/.style={fill=red}]
>  \draw[xshift=1.85cm] node[right,text width=6cm,information text]
>  {
>  The \color[green]{angle $\alpha$} is
>    $30^\circ$ in the example ($\pi/6$ in radians). The \color[red]{sine
>      of $\alpha$}, which is the height of the red line, is
>  \startformula
>  \color[red]{\sin \alpha} = 1/2.
>  \stopformula
>  By the Theorem of Pythagoras ...
>  };
>
> Is ConTeXt correctly parsing the key "information tex/.style"?

Works fine here. The text/.style syntax is new in Tikz. Are you using the 
cvs version of tikz?

Aditya
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19 17:57         ` Aditya Mahajan
@ 2008-02-19 18:30           ` Jesse Alama
  2008-02-19 18:54             ` Jesse Alama
  0 siblings, 1 reply; 11+ messages in thread
From: Jesse Alama @ 2008-02-19 18:30 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

Aditya Mahajan <adityam@umich.edu> writes:

> On Tue, 19 Feb 2008, Jesse Alama wrote:
>
>> Aditya Mahajan <adityam@umich.edu> writes:
>>
>>>> The example features some \definecolor's which I just did away with
>>>> (sadly) by simply substituting their defining values for their
>>>> occurences.  (This is unfortunate, but perhaps necessary until some
>>>> other mechanism is produced.)  The problem is that the text box to the
>>>> right of the picture is supposed to be colored, and with rounded
>>>> corners.  But the box is missing.  Look at p. 20 of
>>>
>>> The TikZ manual make a lot of uses of the xcolor syntax
>>> (e.g. \color{red!20}). There is no equivalent ConTeXt syntax. You need
>>> to define a color, say lightred, as follows
>>>
>>> \definecolor[lightred][r=0.2]
>>>
>>> For tikz key-value options, pgf works behind the scene to define
>>> appropriate colors, so xcolor syntax works for them. So
>>> \fill[fillcolor=red!20] will work as expected. However, when using
>>> \color inside any box, you need to follow ConTeXt syntax. So
>>> \color[red!20] will not work, you need to define a context color and
>>> then use that.
>>
>> I'm still not able to get fillcolor to work with the information box:
>>
>>  \starttikzpicture[scale=4,information text/.style={fill=red}]
>>  \draw[xshift=1.85cm] node[right,text width=6cm,information text]
>>  {
>>  The \color[green]{angle $\alpha$} is
>>    $30^\circ$ in the example ($\pi/6$ in radians). The \color[red]{sine
>>      of $\alpha$}, which is the height of the red line, is
>>  \startformula
>>  \color[red]{\sin \alpha} = 1/2.
>>  \stopformula
>>  By the Theorem of Pythagoras ...
>>  };
>>
>> Is ConTeXt correctly parsing the key "information tex/.style"?
>
> Works fine here. The text/.style syntax is new in Tikz. Are you using
> the cvs version of tikz?

No, I'm using the module from the garden, corresponding to the 1.18
release.  I just installed the CVS version, and, after recompiling, I
see that the backgrounds are still missing.  One possible explanation:
I'm using the old TPM file that's on the modules page.  That should be
updated to reflect the file structure of the new CVS version, right?

Jesse

-- 
Jesse Alama (alama@stanford.edu)
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: colors in pgf within context
  2008-02-19 18:30           ` Jesse Alama
@ 2008-02-19 18:54             ` Jesse Alama
  0 siblings, 0 replies; 11+ messages in thread
From: Jesse Alama @ 2008-02-19 18:54 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

Jesse Alama <alama@stanford.edu> writes:

> Aditya Mahajan <adityam@umich.edu> writes:
>
>> On Tue, 19 Feb 2008, Jesse Alama wrote:
>>
>>> Aditya Mahajan <adityam@umich.edu> writes:
>>>
>>>>> The example features some \definecolor's which I just did away with
>>>>> (sadly) by simply substituting their defining values for their
>>>>> occurences.  (This is unfortunate, but perhaps necessary until some
>>>>> other mechanism is produced.)  The problem is that the text box to the
>>>>> right of the picture is supposed to be colored, and with rounded
>>>>> corners.  But the box is missing.  Look at p. 20 of
>>>>
>>>> The TikZ manual make a lot of uses of the xcolor syntax
>>>> (e.g. \color{red!20}). There is no equivalent ConTeXt syntax. You need
>>>> to define a color, say lightred, as follows
>>>>
>>>> \definecolor[lightred][r=0.2]
>>>>
>>>> For tikz key-value options, pgf works behind the scene to define
>>>> appropriate colors, so xcolor syntax works for them. So
>>>> \fill[fillcolor=red!20] will work as expected. However, when using
>>>> \color inside any box, you need to follow ConTeXt syntax. So
>>>> \color[red!20] will not work, you need to define a context color and
>>>> then use that.
>>>
>>> I'm still not able to get fillcolor to work with the information box:
>>>
>>>  \starttikzpicture[scale=4,information text/.style={fill=red}]
>>>  \draw[xshift=1.85cm] node[right,text width=6cm,information text]
>>>  {
>>>  The \color[green]{angle $\alpha$} is
>>>    $30^\circ$ in the example ($\pi/6$ in radians). The \color[red]{sine
>>>      of $\alpha$}, which is the height of the red line, is
>>>  \startformula
>>>  \color[red]{\sin \alpha} = 1/2.
>>>  \stopformula
>>>  By the Theorem of Pythagoras ...
>>>  };
>>>
>>> Is ConTeXt correctly parsing the key "information tex/.style"?
>>
>> Works fine here. The text/.style syntax is new in Tikz. Are you using
>> the cvs version of tikz?
>
> No, I'm using the module from the garden, corresponding to the 1.18
> release.  I just installed the CVS version, and, after recompiling, I
> see that the backgrounds are still missing.  One possible explanation:
> I'm using the old TPM file that's on the modules page.  That should be
> updated to reflect the file structure of the new CVS version, right?

I spoke too soon -- it looks like things work just fine.  Thanks for
your help!

Jesse

-- 
Jesse Alama (alama@stanford.edu)
___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-02-19 18:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m2bq6dvj38.fsf@DNab422469.Stanford.EDU>
2008-02-19  2:43 ` colors in pgf within context Aditya Mahajan
2008-02-19  3:33   ` Jesse Alama
2008-02-19  3:47     ` Aditya Mahajan
     [not found]       ` <alpine.DEB.1.00.0802182252560.21564@nqv-yncgbc>
2008-02-19  4:56         ` Jesse Alama
2008-02-19  8:20       ` Alan BRASLAU
2008-02-19 16:33         ` Aditya Mahajan
2008-02-19 17:36       ` Jesse Alama
2008-02-19 17:57         ` Aditya Mahajan
2008-02-19 18:30           ` Jesse Alama
2008-02-19 18:54             ` Jesse Alama
2008-02-19  8:50     ` 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).