仅用彩色粗线装饰路径

仅用彩色粗线装饰路径

是否可以只用路径上方或下方的粗彩色线条来装饰路径?在下面的例子中,我手动伪造了结果,但如何使用装饰来实现呢?特别是我希望能够选择颜色和线宽并使用装饰的提升选项。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
   \coordinate (A) at (0,0);
   \coordinate (B) at (1,1);
   \coordinate (v) at ($(B) - (A)$);

   \path let \p1 = (v) in ($1/(\x1^2 + \y1^2)^(0.5)*(\y1,-\x1)$) coordinate (p);
   \pgfmathsetmacro{\dist}{0.7}
   \coordinate (AA) at ($(A) + \dist*(p)$);
   \coordinate (BB) at ($(B) + \dist*(p)$);

   \draw (A) -- (B);
   \draw[thick,orange] (AA) -- (BB);
\end{tikzpicture}
\end{document}

输出

编辑:如果无法通过装饰来获取它,是否可以定义一种仅用于直线的样式,使您可以绘制两条或三条彩色线条,就像这里一样:https://tex.stackexchange.com/a/36858/4011在圆圈的情况下。

答案1

在这里使用有double帮助吗?

\documentclass{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}
   \coordinate (A) at (0,0);
   \coordinate (B) at (1,1);
   \coordinate (v) at ($(B) - (A)$);

   \path let \p1 = (v) in ($1/(\x1^2 + \y1^2)^(0.5)*(\y1,-\x1)$) coordinate (p);
   \pgfmathsetmacro{\dist}{0.7}
   \coordinate (AA) at ($(A) + \dist*(p)$);
   \coordinate (BB) at ($(B) + \dist*(p)$); 
   \draw[line width=5pt,orange,double=black,double distance=1pt] (AA) -- (BB);

   \begin{scope}[xshift=4cm]
   \draw[very thick, orange,double=black,double distance=1pt] (-0.1,5) .. controls (-4,-2) and (4,-2) .. (0.1,5);
   \end{scope}

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容