I'm trying to create a smooth gradient between cyan and blue connecting two shapes, one drawn in cyan and one in blue.
For that I use a simple mix of the two colors in a \foreach
loop.
However, in the first step of the mix, despite having only 0.5% blue mixed with (presumably) 99.5% cyan, the resulting color differs drastically from pure cyan.
What am I missing and how can the effect be properly achieved?
To be clear: what colors and in what ratios should be mixed to achieve the first step from pure cyan towards pure blue?
MWE:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[cyan,fill=cyan] (0,0) rectangle (1,1);
\draw[blue!0.5!cyan,fill=blue!0.5!cyan] (1,0) rectangle (2,1);
\end{tikzpicture}
\end{document}
and the output:
Here is the problem presented while using \shade
:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade[left color=blue,right color=cyan] (0,0) rectangle (2,1);
\draw[cyan,fill=cyan] (2,0) rectangle (3,1);
\end{tikzpicture}
\end{document}
and the result:
The problem was solved by @PaulGaborit and @percusse as can be seen in the comments below by setting:
\colorlet{cyan}[rgb]{cyan}
If I understand correctly, xcolor decides what color scheme to use (rgb/cym) according to the default scheme of the first color in the mix, and uses the predefined name of the second color (in this case 'cyan') under the first color's scheme. Therefore, when using basic colors from differing schemes, the higher boundary of the mix (when the second color is dominant) may differ from the default, 'pure' color.
Section 2.3.2 on page 15 of the xcolor manual (V2.11) kind of suggests that this is what happens, in retrospect.
Best Answer
The
xcolor
package definesblue
as a RGB color andcyan
as a CMY color.To make a mix,
xcolor
uses the color model of the first color and, if necessary, converts the second color.To convert the CMY
cyan
to RGBcyan
, you may add\colorlet{cyan}[rgb]{cyan}
in your preamble.Extract from
xcolor
manual (section 2.3.2 "Meaning of standard color expressions", p. 15, v2.11):Here is an example with three rows: default models, pure rgb model and pure cmy model.