我正在尝试在 tikz 中对狄拉克锥体进行着色,但颜色定义让我头疼,因为 RGB 颜色太暗了。将所有颜色设置为{rgb:red,1;green,1;blue,1}
深灰色而不是白色,所以我认为颜色混合有问题:
下面是我想要用于主体的实际 RGB 颜色的示例代码:
\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}
也许你知道我做错了什么。谢谢!
答案1
使用以下解决方案\definecolor
:
\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}