# In TikZ, is it possible to have paths smoothly join a node?

\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node at (0,0) (O) {} ;
\foreach \a in {0,10,...,360}
{
\draw (\a:0.25) to (O);
}
\end{tikzpicture}

\end{document}

The example code above draws the following picture

and you can see that the lines do not join the boundary of the node with a nice bevel. The effect is ragged.

I believe it would be possible, using a filled node and drawing lines to O.center on a background layer, to produce a smooth picture. But my question is can the lines be "joined" to the node in a smooth way?

Edited to clarify what is meant by "smooth"

This is a line joining a shape where the join is not smooth.

This is a line joining a shape where the join is smooth.

Perhaps it's a case of joining two separate paths. I seem to recall that Adobe Illustrator has that capability.

Very similar to percusse's answer except that I do not draw the rectangle explicitly, i.e. if the node size changes, one does not have to adjust the dimensions of the rectangle.

\documentclass[tikz,border=2pt]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\node[red,draw=white, line width=1mm] at (0,0) (O) {} ;
\begin{scope}[on background layer]
\foreach \a in {0,10,...,360}
{
\draw (O.{\a}) to (\a:0.25) ;
}
\end{scope}
\end{tikzpicture}
\end{document}

• Just in case, if needed tex.stackexchange.com/questions/53184/… Apr 15 '18 at 14:42
• @percusse Yes, this might be even better.
– user121799
Apr 15 '18 at 14:43
• I really need to learn how to clip properly. Apr 15 '18 at 21:46

You can clip it with a shape and a circle.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}[] % clip is only valid inside this scope
\clip (-0.5,-0.5) rectangle (0.5,0.5) (0,0) circle(2);
\foreach\a in{0,10,...,350}{\draw[ultra thick] (0,0)--+(\a:1);}
\end{scope}
\end{tikzpicture}
\end{document}

• I tried \clip (O.south west) rectangle (O.north east) (0,0) circle(2); to exactly match the boundaries of the node, but it didn't quite work as expected. Apr 15 '18 at 21:57
• @pheon For a node, you need to zero out the outer sep if you want a tight connection. And take the line width into account. Apr 16 '18 at 8:30

If you use a circular node, you get some sort of a nicer output

\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node[circle] at (0,0) (O) {} ;
\foreach \a in {0,10,...,360}
{
\draw (\a:0.25) to (O);
}
\end{tikzpicture}
\end{document}

EDIT: The thing is that you are exactly attaching the lines to the node box, see below the with the red lines connecting to the black box.

\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node[draw=black,outer sep=0pt] at (0,0) (O) {} ;
\foreach \a in {0,10,...,360}
{
\draw[red] (\a:0.25) -- (O);
}
\end{tikzpicture}
\end{document}

• Sure. This smooths the node to match the direction of the lines. But my question was meant to be about smoothly attaching a line to a generically shaped node. Or indeed, another line, not in the same path. Apr 15 '18 at 13:47
• To be sure, what exactly do you mean by smooth attach ? I edited my answer to show you that you lines exactly connect to the node box. Do you mean you'd like to have the lines connecting perpendicularly to the box ? Please clarify Apr 15 '18 at 13:58