TikZ:如何提取路径的一部分以供日后使用

TikZ:如何提取路径的一部分以供日后使用

我想知道是否有办法提取命名路径的某些部分,并在以后使用该部分进行描边。在我的示例中,我想描边中间的线(名为 mitte 的路径)从图片左侧到文本开头(名为 (A) 的交叉点)以及从文本结尾(名为 (E) 的交叉点)到图片右侧。重要的是文本后面不绘制任何内容。 部分路径未绘制的图片

在代码中我包含了两行伪代码来展示我想要做的事情。

\documentclass[tikz, border=5mm]{standalone}
\usepackage[T1]{fontenc}
\usetikzlibrary{decorations.text,intersections,calc}

\begin{document}
\Huge \bfseries
\catcode`\|12
\begin{tikzpicture}[decoration={text along path, text={Blablablablablabla}, text align={left indent=10.0mm}}]
  \draw[rounded corners] (9.0,2.25) -- (11.5,2.25) .. controls (13.0,2.25) and (13.0,4.25) .. (20.5,4.25);
  \draw[name path=mitte, rounded corners] (9.0,1.25) -- (11.5,1.25) .. controls (13.0,1.25) and (13.0,3.25) .. (20.5,3.25);
  \draw[rounded corners] (9.0,0.25) -- (11.5,0.25) .. controls (13.0,0.25) and (13.0,2.25) .. (20.5,2.25);
  \draw[decorate, above=6mm] (11.5,0.25) .. controls (13.0,0.25) and (13.0,2.25) .. (20.5,2.25);
  \draw[name path=anfang] (12.1,4.5) -- (12.1, 0.0);
  \draw[name path=ende] (19.6,4.5) -- (19.6, 0.0);
  \path[name intersections={of=mitte and anfang, by=A}];
  \path[name intersections={of=mitte and ende, by=E}];
  %--> \draw[along path=mitte] from beginning to (A);
  %--> \draw[along path=mitte] from (E) to end;
\end{tikzpicture}
\end{document}

有什么建议么?

答案1

只需\clip在 内即可scope。人们认为,无论曲线如何修剪或取消修剪,其绘制方式都相同。它们不应该看起来不一样在图示部分。顺便说一下,我们也可以剪切剪切曲线进行更复杂的绘图;例如:如何在 TikZ 中反转“剪辑”选择?

\documentclass[tikz, border=5mm]{standalone}
\usepackage[T1]{fontenc}
\usetikzlibrary{decorations.text,intersections,calc}

\begin{document}
\Huge \bfseries
\catcode`\|12
\begin{tikzpicture}[decoration={text along path, text={Blablablablablabla}, text align={left indent=10.0mm}}]
\draw[rounded corners] (9.0,2.25) -- (11.5,2.25) .. controls (13.0,2.25) and (13.0,4.25) .. (20.5,4.25);
\begin{scope}
    \clip(9.0,0.0)rectangle(12.1,4.25)(20.5,0.0)rectangle(19.6,4.25);
    \draw[name path=mitte, rounded corners] (9.0,1.25) -- (11.5,1.25) .. controls (13.0,1.25) and (13.0,3.25) .. (20.5,3.25);
\end{scope}
\draw[rounded corners] (9.0,0.25) -- (11.5,0.25) .. controls (13.0,0.25) and (13.0,2.25) .. (20.5,2.25);
\draw[decorate, above=6mm] (11.5,0.25) .. controls (13.0,0.25) and (13.0,2.25) .. (20.5,2.25);
\draw[name path=anfang] (12.1,4.5) -- (12.1, 0.0);
\draw[name path=ende] (19.6,4.5) -- (19.6, 0.0);
%\path[name intersections={of=mitte and anfang, by=A}];
%\path[name intersections={of=mitte and ende, by=E}];
%--> \draw[along path=mitte] from beginning to (A);
%--> \draw[along path=mitte] from (E) to end;
\end{tikzpicture}
\end{document}

相关内容