如何扩展该图中的阴影?

如何扩展该图中的阴影?

下图是轮廓图。如何将当前的阴影延伸到图的其余部分,以便所有线条之间都有阴影?

这是图和代码。

在此处输入图片描述

\documentclass[tikz]{standalone}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}
  \newcounter{cntShader}
  \setcounter{cntShader}{60}
  \coordinate (o) at (0,0);
  \draw[->] (o) -- (+80:4) coordinate (b);
  \draw[->] (o) -- (-80:4) coordinate (c);
  \draw (o) -- (+170:3);
  \draw (o) -- (-170:3);
  \foreach \rad in {3,2.5,...,.5} {
    \draw pic[draw,fill=gray!\thecntShader, angle radius=\rad cm] {angle=c--o--b};
    \pgfmathsetcounter{cntShader}{\thecntShader-10}
    \setcounter{cntShader}{\thecntShader}
    \draw (+80:\rad cm) -- +(+170:3cm);
    \draw (-80:\rad cm) -- +(-170:3cm);
  }
\end{tikzpicture}
\end{document}

答案1

这样就可以了(但不是获得结果的最简单方法)。

\documentclass[tikz]{standalone}
\usetikzlibrary{angles}
\begin{document}
\begin{tikzpicture}
  \newcounter{cntShader}
  \setcounter{cntShader}{60}
  \coordinate (o) at (0,0);
  \draw[->] (o) -- (+80:4) coordinate (b);
  \draw[->] (o) -- (-80:4) coordinate (c);
  \draw (o) -- (+170:3);
  \draw (o) -- (-170:3);
  \foreach \rad in {3,2.5,...,.5} {
    \draw pic[draw,fill=gray!\thecntShader, angle radius=\rad cm] {angle=c--o--b};
    \path (+80:\rad cm-0.5cm) +(+170:3cm) coordinate (auxp)
    (-80:\rad cm-0.5cm) +(-170:3cm) coordinate (auxm);
    \path[fill=gray!\thecntShader] (+80:\rad cm) -- +(+170:3cm) -- (auxp)
     -- (+80:\rad cm-0.5cm) -- cycle;
    \path[fill=gray!\thecntShader] (-80:\rad cm) -- +(-170:3cm) -- (auxm)
     -- (-80:\rad cm-0.5cm) -- cycle;
    \pgfmathsetcounter{cntShader}{\thecntShader-10}
    \setcounter{cntShader}{\thecntShader}
    \draw (+80:\rad cm) -- +(+170:3cm);
    \draw (-80:\rad cm) -- +(-170:3cm);
  }
\end{tikzpicture}
\end{document}

在此处输入图片描述

我个人会选择一条可能更简单的路径:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[line join=bevel]
  \coordinate (o) at (0,0);
  \foreach \rad [count=\Z starting from 0] in {3,2.5,...,.5}  {
  \pgfmathtruncatemacro{\GL}{60-10*\Z}
  \draw[line width=5mm,gray!\GL] (+80:\rad cm-0.25cm) +(+170:3cm) -- (+80:\rad cm-0.25cm)
  arc(80:-80:\rad cm-0.25cm) -- ++ (-170:3cm);
  \draw (+80:\rad cm) +(+170:3cm) -- (+80:\rad cm)
  arc(80:-80:\rad cm) -- ++ (-170:3cm);}
  \draw (+170:3cm) -- (o) -- (-170:3cm);
  \draw[<->] (+80:4) coordinate (b) -- (o) -- (-80:4) coordinate (c);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

像这样:

在此处输入图片描述

以下是代码:

\documentclass[tikz, border=20mm]{standalone}
\usetikzlibrary{angles,calc}
\begin{document}
\begin{tikzpicture}
  \newcounter{cntShader}
  \setcounter{cntShader}{60}
  \coordinate (o) at (0,0);
  \draw[->] (o) -- (+80:4) coordinate (b);
  \draw[->] (o) -- (-80:4) coordinate (c);
  \draw (o) -- (+170:3);
  \draw (o) -- (-170:3);
  \foreach \rad [evaluate=\rad as \prad using {\rad-0.5}, count=\c,
                 evaluate=\c as \sh using {70-10*\c}] in {3,2.5,...,.5} {
    \draw pic[draw,fill=gray!\sh, angle radius=\rad cm] {angle=c--o--b};
    \draw[fill=gray!\sh](+80:\prad cm)--(+80:\rad cm)--++(170:3cm)--($(+80:\prad cm)+(170:3cm)$)--cycle;
    \draw[fill=gray!\sh](-80:\prad cm)--(-80:\rad cm)--++(-170:3cm)--($(-80:\prad cm)+(-170:3cm)$)--cycle;
  }
\end{tikzpicture}
\end{document}

还请注意,我在语句中用usingcntShader替换了您的内容。\shcount=\c, evaluate=\c as \sh using {70-10*\c}\foreach

相关内容