6

I want to know if there is a way to extract some part of a named path and use this part later on for e.g. stroking. In my example, I want to stroke the line in the middle (the path named mitte) from the picture's left side to the beginning of the text (intersection named (A)) and from the end of the text (intersection named (E)) to the picture's right side. It's important that nothing is drawn behind the text. picture with part of path not to be drawn

In the code I included two lines of pseudo code to show what I would like to do.

\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}

Any suggestions?

  • 2
    related: http://tex.stackexchange.com/questions/26627/saving-and-reusing-combining-paths-in-tikz – jub0bs Aug 09 '14 at 11:12
  • Thanks for the link. I looked into it, but I can't find how I could use it for my problem. Maybe my imagination is too limited... I even read the manual about soft paths but I can't figure out how to interrupt my path at coordinate (A) for being able to save it. – panikschaf Aug 09 '14 at 13:29
  • You could clip the line. See manual starting on page 178. – John Kormylo Aug 10 '14 at 16:13
  • Yes, that's what I wanted to do in the first place. But the problem is that I want to draw some part of the curved line which is defined with control points that lie in the clipped area. Starting the clipping at (A) I cannot specify the exact path because the curve would then look different (using the same control points). Of course, I could tweak around until I find the new control points for that bit of the curve to be shown. But that's annoying and won't be "perfect"... But maybe I will have to do just that :-( – panikschaf Aug 10 '14 at 16:33

1 Answers1

3

Just \clip it within a scope. It is believed that curves are drawn in the same way no matter how they are clipped or unclipped. They should not look different in the shown part. By the way, we can also clip the clipping curves to perform more complex drawings; for example: How can I invert a 'clip' selection within 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}

Symbol 1
  • 36,855