如何限制径向褪色 Tikzpicture 的圆形跨度

如何限制径向褪色 Tikzpicture 的圆形跨度

考虑一下代码

\documentclass{book}
% Code can be compiled with Pdflatex or Xelatex
\usepackage{tikz} 
\usetikzlibrary{fadings}
\definecolor{darkamber}{RGB}{213,54,0}
\definecolor{sunriseyellow}{RGB}{255,219,0}
\definecolor{topaz}{RGB}{255,200,124}

\begin{document}
\thispagestyle{empty}

\tikzfading[name=fade out, inner color=transparent!0,
outer color=transparent!100]
\tikzset{
  star/.style={darkamber, fill=white, path fading=fade out}
}
\begin{tikzpicture}
  \clip (-3, -3) rectangle (3, 3);
  \draw[black, shading=mradial, inner color=topaz, 
  middle color=darkamber!60!sunriseyellow, outer color=darkamber]
  (-3, -3) rectangle (3, 3);
\end{tikzpicture} 

\end{document}

产生圆形放射状效果

在此处输入图片描述

问题:我不想让径向渐变覆盖整个圆,而是希望显示从 -60 度到 240 度的径向圆部分(即,我想从纯暗琥珀色背景中移除上图覆盖 240-300 度的径向效果)。我该怎么做?

谢谢。

答案1

作为对我上述评论的补充,以下是我想到的最简单的解决方案。只需在阴影上方绘制饼图即可。

阴影但不是全部

\documentclass{book}
% Code can be compiled with Pdflatex or Xelatex
\usepackage{tikz} 
\usetikzlibrary{fadings}
\definecolor{darkamber}{RGB}{213,54,0}
\definecolor{sunriseyellow}{RGB}{255,219,0}
\definecolor{topaz}{RGB}{255,200,124}

\begin{document}
\thispagestyle{empty}

\tikzfading[name=fade out, inner color=transparent!0,
outer color=transparent!100]
\tikzset{
  star/.style={darkamber, fill=white, path fading=fade out}
}
\begin{tikzpicture}
  \clip (-3, -3) rectangle (3, 3);
  \draw[black, shading=mradial, inner color=topaz, 
  middle color=darkamber!60!sunriseyellow, outer color=darkamber]
  (-3, -3) rectangle (3, 3);
  \fill[darkamber] (240:4cm) arc (240:300:4cm) -- (0,0) -- cycle; % <---- The pie piece
\end{tikzpicture} 

\end{document}

相关内容