我想并排绘制两条线,如下所示:
当线条在某些地方弯曲时,很难将它们分开绘制。我尝试了此double
选项,但它会产生三条线。
这是我的代码(分别画出两条线):
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\definecolor{line3}{cmyk}{0.02,0.16,1,0}
\definecolor{line4}{cmyk}{0.86,1,0.03,0.01}
\begin{tikzpicture}
\draw[color=line3,line width=5pt,rounded corners] (0,0) -- ++(1.05,1.05) -- ++(1,0);
\draw[color=line4,line width=5pt,rounded corners] (3.535pt,-3.535pt) -- ++(1,1) -- ++(1,0);
\end{tikzpicture}
\end{document}
答案1
以下示例绘制了两次线。首先,使用较浅的颜色绘制整条线。然后,使用路径为下部制作裁剪区域。最后,使用较深的颜色绘制整条线:
\documentclass{standalone}
\usepackage{tikz}
\definecolor{line3}{cmyk}{0.02,0.16,1,0}
\definecolor{line4}{cmyk}{0.86,1,0.03,0.01}
\begin{document}
\begin{tikzpicture}
\begin{scope}[
line width=10pt,
rounded corners,
]
\def\mypath{(0, 0) -- ++(1, 1) -- ++(1, 0)}
\draw[color=line3] \mypath;
\begin{scope}[overlay]
\clip (-1, -1) -- \mypath -- ++(1, 0) -- ++(0, -2) -- cycle;
\draw[color=line4] \mypath;
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}