Draw curved line in tikz connecting north and south side of a node

linetikz-pgf

I am trying to draw a curved line connecting the north and south side of a tikz node. Currently, the code snippet below shows my rather simplistic attempt with discontinuities between the three paths. Is there a way to easily draw lines starting from the north side of the node rectangle to its south side, for a given x-coordinate (here x=-1.0)?

\documentclass[tikz,border=1mm]{standalone}


\begin{document}

\begin{tikzpicture}
  \node[minimum width=5cm, minimum height=0.5cm, draw] (rectangle) at (0,0) {};
  \path[line width=1mm] (-1.0, 0.25) edge [bend left] (-0.8, 0.35);
  \path[line width=1mm] (-0.8, 0.35) edge[bend left] (-0.8, -0.35);
  \path[line width=1mm] (-0.8, -0.35) edge[bend left] (-1.0, -0.25);
\end{tikzpicture}

\end{document}

Best Answer

You can use invclip style to define a non drawn area over which you draw the elipse. It's important to define the area from top west corner to south east corner.

\documentclass[tikz,border=1mm]{standalone}

\tikzset{invclip/.style={clip,insert path={{[reset cm]
        (-\maxdimen,-\maxdimen) rectangle (\maxdimen,\maxdimen)}}}}

\begin{document}

\begin{tikzpicture}[scale=1.0]
  \node[minimum width=5cm, minimum height=0.5cm, draw] (rectangle) at (0,0) {};
  \pgfmathsetmacro{\angle}{asin(0.25/0.35)}%
  \draw (-1, 0.25) arc[start angle={180-\angle}, end angle={-180+\angle}, y radius=0.35, x radius=0.2];

    \begin{scope}
        \begin{pgfinterruptboundingbox}
            \path[invclip] (0.6,0|-rectangle.north) rectangle (1,0|-rectangle.south);
        \end{pgfinterruptboundingbox}
        \draw[blue] (1,0) circle[x radius=0.2, y radius= 0.35];  
    \end{scope}

\end{tikzpicture}

\end{document}

enter image description here