1

I am trying to shade a dirac cone in tikz, but the color definitions give me a headache as RGB colors are way too dark. Setting all colors to{rgb:red,1;green,1;blue,1} would five a dark grey instead of white, so I think something is wrong with the color mixing:

enter image description here

Here is my sample code with the actual RGB colors that I want to use for the body:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\def\h{6}
\def\a{2}
\def\b{0.5}
\def\shadebody{\fill[
    left color={rgb:red,65;green,134;blue,198},
    right color={rgb:red,65;green,134;blue,198},
    middle color={rgb:red,126;green,169;blue,208},
    shading=axis,
    opacity=1
    ] }
\def\shadetop{\fill[
    top color={rgb:red,65;green,134;blue,198},
    bottom color={rgb:red,65;green,134;blue,198},
    %middle color={rgb:red,126;green,169;blue,208},
    shading=axis,
    opacity=1
    ] }


\shadebody
  (\a,0) -- (0,\h) -- (-\a,0) arc (180:360:\a cm and \b cm);
\draw[line width = 0.5pt] 
  (-\a,0) arc (180:360:\a cm and \b cm) -- (0,\h) -- cycle;

  %upper part
\shadetop
(0,2*\h) circle (\a cm and \b cm);

\shadebody
  (\a,2*\h) -- (0,\h) -- (-\a,2*\h) arc (180:360:\a cm and \b cm);
  \draw[line width = 0.5pt] 
  (-\a,2*\h) arc (180:360:\a cm and \b cm) -- (0,\h) -- cycle;

  \draw[line width = 0.5pt] 
  (\a,2*\h) arc (0:180:\a cm and \b cm);






\end{tikzpicture}

\end{document}

This is what I get next to what the gradient looks like in illustrator: enter image description here

Maybe you know what I am doing wrong. Thanks!

2
  • the scale is 0,0,0=black, 255,255,255=white, so 1,1,1=dark gray sounds about right Sep 20, 2015 at 10:05
  • The scale is percental, so 255,255,255 gives the same as 1,1,1.
    – ElDoe
    Sep 20, 2015 at 10:36

1 Answer 1

3

A solution using \definecolor:

enter image description here

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\def\h{6}
\def\a{2}
\def\b{0.5}
\definecolor{top}{RGB}{65,134,198}
\definecolor{middle}{RGB}{126,169,208}
\def\shadebody{\fill[
    left color=top,
    right color=top,
    middle color=middle,
    shading=axis,
    opacity=1
    ] }
\def\shadetop{\fill[
    top color=top,
    bottom color=top,
    middle color=middle,
    shading=axis,
    opacity=1
    ] }


\shadebody
  (\a,0) -- (0,\h) -- (-\a,0) arc (180:360:\a cm and \b cm);
\draw[line width = 0.5pt] 
  (-\a,0) arc (180:360:\a cm and \b cm) -- (0,\h) -- cycle;

  %upper part
\shadetop
(0,2*\h) circle (\a cm and \b cm);

\shadebody
  (\a,2*\h) -- (0,\h) -- (-\a,2*\h) arc (180:360:\a cm and \b cm);
  \draw[line width = 0.5pt] 
  (-\a,2*\h) arc (180:360:\a cm and \b cm) -- (0,\h) -- cycle;

  \draw[line width = 0.5pt] 
  (\a,2*\h) arc (0:180:\a cm and \b cm);






\end{tikzpicture}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .