# Different radii of rounded corners in same draw command in TikZ

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}

-
Possible duplicate of TikZ rectangular node with different rounded corners –  Peter Grill Feb 19 '13 at 18:43
If the above linked question does not solve your issue, please update the question as to why. Otherwise this will probably be closed as a duplicate. –  Peter Grill Feb 19 '13 at 18:44
@PeterGrill Even if I use the method described in the answer to the question linked, I still can't use filldraw as far as I can tell. If I would't fill the shape the other solution would work. –  Hugo Feb 19 '13 at 18:52
Can you show us in a MWE what you tried? So we can proof on our own computer what you have done and test if it is working for us ... –  Kurt Feb 19 '13 at 19:30
Oh, that didn't format very well. How am I supposed to give you the code? –  Hugo Feb 19 '13 at 21:45

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}

-
Is there a list of settings which can be used this way? It doesn't work for line width or line color I assume. –  Stephan Lehmke Feb 19 '13 at 19:06
@StephanLehmke: Ah, that would be useful indeed. No, it doesn't work for colour, width, line join, or most other options. I think it only works for things that have more to do with path construction (radius for circles, for example) than with the actual path representation. –  Jake Feb 19 '13 at 19:11
@StephanLehmke Unfortunately, the PGF manual is very unspecific about that (section 14: “Some options […]”). @Jake you might add, that this option can also be “scoped” which removes the need to repeat rounded corners=3, e.g. \path[rounded corners=3] <radius is 3> { [rounded corners=1] <radius is 1> } <radius is 3 again>;. –  Qrrbrbirlbel Feb 19 '13 at 19:23
@Qrrbrbirlbel: Good point! I've edited my answer. Thanks! –  Jake Feb 19 '13 at 23:36