如何绘制一个圆锥体,并为其底部(圆)以外的部分着色。然后从着色部分绘制箭头并添加注释?
答案1
这是尝试为圆锥体创建有点逼真的阴影。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{fadings}
\tikzfading[name=fade cone,
left color=transparent!100,
right color=transparent!100,
middle color=transparent!30,shading angle=100]
\begin{document}
\begin{tikzpicture}[upper cone/.style={insert path={
(174:2 and 0.4) arc(174:6:2 and 0.4) -- (0,3) -- cycle}}]
\draw[fill=blue,upper cone];
\begin{scope}
\clip[upper cone];
\fill[white,path fading=fade cone] (-2,-0.4) rectangle (2.7,3);
\end{scope}
\draw (174:2 and 0.4) arc(174:366:2 and 0.4);
\draw[stealth-] (0.3,1.4) -- ++ (2,1) node[right,align=left]{some\\text};
\end{tikzpicture}
\end{document}
通过对内侧进行阴影处理,我们可以让它变得更有趣;通过删除一些硬编码值而使用计算量,我们可以让它变得更加灵活。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{fadings,calc}
\tikzfading[name=fade cone,
left color=transparent!100,
right color=transparent!100,
middle color=transparent!30,shading angle=100]
\tikzfading[name=inner cone,
left color=transparent!30,
right color=transparent!30,
middle color=transparent!100,shading angle=80]
\begin{document}
\begin{tikzpicture}[upper cone/.style={insert path={
(174:2 and 0.4) arc(174:6:2 and 0.4) -- (0,3) -- cycle}}]
\draw[fill=blue,upper cone];
\begin{scope}[local bounding box=fore]
\clip[upper cone];
\fill[white,path fading=fade cone]
let \p1=($(fore.north east)-(fore.south west)$),
\n1={-\x1*cos(100)/2},\n2={max(\x1,\y1)} in
(fore.south west) rectangle ++ (\n2+\n1,\n2);
\end{scope}
\draw[fill=blue] circle[x radius=2cm,y radius=0.4cm];
\begin{scope}[local bounding box=back]
\clip circle[x radius=2cm,y radius=0.4cm];
\fill[black,path fading=inner cone]
let \p1=($(back.north east)-(back.south west)$),
\n1={-\x1*cos(100)/2},\n2={max(\x1,\y1)} in
(back.north east) rectangle ++ (-\n2-\n1,-\n2);
\end{scope}
\draw[stealth-] (0.3,1.4) -- ++ (2,1) node[right,align=left]{some\\text};
\end{tikzpicture}
\end{document}
当然,这并不现实。