[Tex/LaTex] Different radii of rounded corners in same draw command in TikZ

technical-drawingtikz-pgf

Is it possible to use different rounded corners radii on different parts of a draw command?

I'm creating a tube that is bent. I'd like the outer radius to be greater than the inner radius. I can of course do this by creating two different draw commands, but then I won't be able to fill the object.

\filldraw[draw=blue!50, fill=black!10, rounded corners=2] (1.9,15) -- (3.1,15) -- (3.1,14.6)
-- (3.3,14.6) -- (3.3,15.2) -- (3.5,15.2)-- (3.5,13.9) -- (3.3,13.9) --(3.3,14.5) --
(3.1,14.5) -- (3.1,14.1) -- (1.9,14.1) -- cycle;

I've tried the following, but it generated a white diamond-shape in the middle of the figure that was supposed to be green.

\documentclass[border=3mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\filldraw node[fill=green,
append after command={[rounded corners=0pt](b.west)|-(b.north)},
append after command={[rounded corners=3pt](b.north)-|(b.east)},
append after command={[rounded corners=1pt](b.east)|-(b.south)},
append after command={[rounded corners=5pt](b.south)-|(b.west)}] (b) {Another piece of text};
\end{tikzpicture}

\end{document}

Best Answer

Yes, the rounded corners key can be specified at several points along the path with different values by adding [rounded corners=<value>] in the path, which will then be active until the end of the path or until the next rounded corners key. Alternatively, as Qrrbirlbel pointed out in a comment, you can also keep the option local to part of the path by enclosing it in { ... }. I've used both approaches in the example below:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\filldraw[draw=blue!50, fill=black!10, rounded corners=3] (1.9,15)
-- (3.1,15) {[rounded corners=1]
-- (3.1,14.6) 
-- (3.3,14.6)}
-- (3.3,15.2)
-- (3.5,15.2)
-- (3.5,13.9)
-- (3.3,13.9) [rounded corners=1]
-- (3.3,14.5)
-- (3.1,14.5) [rounded corners=3]
-- (3.1,14.1) -- (1.9,14.1) -- cycle;
\end{tikzpicture}
\end{document}