2

In theory, additive mixing Red color and Green color produces Yellow color.

In my mental model, additive mixing opaque Red and opaque Green will produce opaque Yellow.

But the following attempt, I got a result that is different from my mental model.

WHY?

alt text

Minimal Code (PSTricks)

\documentclass[dvipsnames,dvips,rgb]{minimal}
\usepackage{pstricks}

\begin{document}
\begin{pspicture}(3,3)
  \psset{fillstyle=solid,opacity=0.5,linestyle=none}
    \pscircle[fillcolor=red](1,1){1}  
    \pscircle[fillcolor=green](2,1){1}  
    \psframe[fillcolor=yellow](0,2)(3,3)
\end{pspicture} 
\end{document}

Minimal Code (PGF/Tikz)

\documentclass[dvipsnames,dvips,rgb]{minimal}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
    \draw [fill=red,opacity=0.5](1,1) circle (1);
    \draw [fill=green,opacity=0.5](2,1) circle (1);
    \draw [fill=yellow,opacity=0.5] (0,2)--(0,3)--(3,3)--(3,2)--cycle;
\end{tikzpicture} 
\end{document}
Display Name
  • 46,933
  • 5
    http://en.wikipedia.org/wiki/Subtractive_color, http://en.wikipedia.org/wiki/Additive_color – Caramdir Jan 01 '11 at 19:37
  • 1
    Is this a question about TeX or friends? – Seamus Jan 01 '11 at 20:03
  • I learned this in primary school :P Couldn't remember much of it, though, as it was some 20 years ago, so thanks @Caramdir... – Vivi Jan 01 '11 at 22:41
  • Your code and question are different. Your code draws two semi-transparent circles; are you asking why their overlap is a brown-yellow color instead of bright yellow? Or are you asking why code such as \fill [red] (0,0) circle (2cm) ; \fill [green] (0,1) circle (2cm) ;, which draws opaque circles, produces no yellowish region at all? – Antal Spector-Zabusky Jan 01 '11 at 22:58
  • @Antal, the question based on the output produced by the codes. Your question confirmation is my question. – Display Name Jan 02 '11 at 03:27
  • @Seamus, do you have an answer? – Display Name Jan 02 '11 at 11:01

1 Answers1

6

The result you get isn't what you expect because tikz is using an rgb colour model; try the following document to see how the colour model matters. Since tikz doesn't support hsb, your intuitive mixing model doesn't work.

\documentclass{article}

\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \draw [fill=red,opacity=0.5](1,1) circle (1);
    \draw [fill=green!50,opacity=0.5](2,1) circle (1);
    \draw [fill=yellow,opacity=0.5] (0,2)--(0,3)--(3,3)--(3,2)--cycle;
\end{tikzpicture}

Equal parts mixture of red!50 and green!50 (rgb model):
{\color{rgb:red!50,1;green!50,1}\rule{1cm}{1cm}}

This is equivalent to your overlapping circles.

Equal parts mixture of red!50 and green!50 (hsb model):
{\color{hsb:red!50,1;green!50,1}\rule{1cm}{1cm}}

This is equivalent to what you expected.

\end{document}
Alan Munn
  • 218,180