我尝试了两种不同的起点:第一个带有切口的渐变矩形,第二个绘制类似于上图的线条。在第一种情况下,我遇到了一个问题,我无法清楚地识别空白处的坐标。在第二种情况下,我不知道如何在线条上创建渐变颜色。无论如何,这些线条有奇怪的结尾/角落。这两个想法都在我的例子中:
\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{center}
\begin{tikzpicture}
\node[rectangle,shading=axis,left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}, shading angle= 30, minimum width=8cm, minimum height=8cm] at (0,0) {};
\fill [white] (-4,-4) -- ++(0,8) -- ++(2,0) -- ++(-2,-8); %left cut
\fill [white] (4,-4) -- ++(0,8) -- ++(-2,0) -- ++(2,-8); % right cut
\fill [white] (0,4) -- (-2,0) -- (-4,3) -- (-4,4) -- (0,4); %
\fill [white] (0,3.5) -- (-1.5,0) -- (0,-2) -- (1.5,0) -- (0,3.6); % white filling below top
\fill [white] (0,4) -- (2,0) -- (4,3) -- (4,4) -- (0,4); %
\end{tikzpicture}
\begin{tikzpicture}[line width=16pt]
\draw[line join=miter] (-6,-6) -- (0,6) -- (6,-6) -- (-6,-6) -- (0,6); %middle
\draw[line join=miter] (-6.2,-6.25) -- (-5.25,1.5) -- (-2,-6) -- (-6,-6); %left
\draw[line join=miter] (-5.3,1.7) -- (2,-6); %left
\draw[line join=miter] (6.2,-6.25) -- (5.25,1.5) -- (2,-6) -- (6,-6); %right
\draw[line join=miter] (5.25,1.5) -- (-2,-6); %right
\end{tikzpicture}
\end{center}
\end{document}
我找到了一个可行的解决方案,但(在代码中)看起来很丑陋:
\fill[shading=axis,left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}, shading angle= 30] (0.01,-2.7) rectangle(2.99,-0.01) ;
\fill [white] (0,-2.7) -- (0.3,-0.75) -- (0.8,-1.3)-- (1.5,0) -- (0,0) -- (0,-2.7); %
\fill [white] (3,-2.7) -- (2.7,-0.75) -- (2.2,-1.3)-- (1.5,0) -- (3,0) -- (3,-2.7); %
\fill [white] (0.2,-2.4) -- (0.57,-1.72) -- (0.37,-1.18); %
\fill [white] (0.53,-1.22) -- (0.73,-1.42) -- (0.66,-1.56); %
\fill [white] (0.27,-2.56) -- (0.90,-2.56) -- (0.64,-1.89); %
\fill [white] (1.03,-2.5) -- (1.41,-2.11) -- (0.84,-1.53) -- (0.73,-1.72); %
\fill [white] (2.8,-2.4) -- (2.43,-1.72) -- (2.63,-1.18); %
\fill [white] (2.47,-1.22) -- (2.27,-1.42) -- (2.34,-1.56); %
\fill [white] (2.73,-2.56) -- (2.10,-2.56) -- (2.36,-1.89); %
\fill [white] (1.97,-2.5) -- (1.59,-2.11) -- (2.16,-1.53) -- (2.27,-1.72); %
\fill [white] (1.5,-2.0) -- (2.11,-1.4) -- (1.5,-0.33) -- (0.89,-1.4); %
\fill [white] (1.5,-2.22) -- (1.85,-2.56) -- (1.15,-2.56); %
代码是通过将图像复制到图形程序并查看像素坐标生成的。这个“解决方案”还有另一个缺点:如果我想要更细或更粗的线条,那么我必须用图形程序创建一个新图像并再次查看坐标。
答案1
我清理了文档和坐标,以使所有内容保持在一个平滑的形状内 - 您可以根据自己的喜好调整坐标:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=16pt]
\draw (-6,-6) -- (0,6) -- (6,-6);
\draw[red] (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle;
\draw[green] (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle;
\draw[blue] (-5.25,1.5) -- (-2,-6);
\draw[yellow] (5.25,1.5) -- (2,-6);
\end{tikzpicture}
\end{document}
同样是黑色,只有一条路径:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=16pt]
\draw (-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle (-5.25,1.5) -- (-2,-6) (5.25,1.5) -- (2,-6);
\end{tikzpicture}
\end{document}
现在我被困住了——它不适用于该fadings
库,我一直在阅读手册和本网站上的许多帖子——它可以通过涉及自定义代码的方法来完成,例如Tikz:对路径进行着色而不进行任何填充
在这次尝试中,有几件事我不太明白 - 例如缩放。有人写道自定义淡入淡出需要 2cmx2cm,而其他人则使用 1cmx1cm。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=myfading]
\fill[transparent!0](-1,-1) rectangle (1,1);
\draw[scale=0.1, line width=1.6pt, path fading=west](-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.25,1.5) -- (2,-6) -- cycle (6,-6) -- (5.25,1.5) -- (-2,-6) -- cycle (-5.25,1.5) -- (-2,-6) (5.25,1.5) -- (2,-6);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\fill[path fading=myfading, fill=black] (-6,-6) rectangle (6,6);
\end{tikzpicture}
\end{document}
编辑:
通过使用来自 OP 的评论和来自 OP 的颜色,我得到了这个结果:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{tikzfadingfrompicture}[name=myfading]
\draw[scale=0.1, line width=2pt, transparent!0](-6,-6) -- (0,6) -- (6,-6) (-6,-6) -- (-5.5,2) -- (2,-6) -- cycle (6,-6) -- (5.5,2) -- (-2,-6) -- cycle (-5.5,2) -- (-2,-6) (5.5,2) -- (2,-6); \fill[black, path fading=north, fading angle = 195](-1,-1) rectangle (1,1);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\fill[path fading=myfading, left color = {rgb,255:red,255;green,215;blue,0}, right color = {rgb,255:red,205;green,133;blue,63}] (-6,-6) rectangle (6,6);
\end{tikzpicture}
\end{document}
仍存在无法解释的扩展问题。