# Drawing a triangle with rounded corners in TikZ

I'm trying to draw a simple equilateral triangle with rounded corners in Tikz. However, I can't get the rounded corners correct.

I have the following MWE which draws the triangle:

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}
\draw [fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}


I've tried this to get rounded corners, but it has a very strange result:

\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{xcolor}
\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}
\draw [rounded corners=10mm,fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}


Any idea how to get simple rounded corners for the three corners of the triangle?

P.S. I'm not sure which libraries are needed, so I've left them all for now but I know this is probably not needed.

-

Make the radius of the rounded corners smaller. Remove =10mm and you will see the instant effect. Also, in your case, I find no need to load the xcolor package since it is used internally by tikz, unless, as noted by Alain Matthes, you use some of its options for naming your colors. You can uncomment it if you like. The libraries are not needed here, too, so I commented them out.

Here is your figure when the 10mm is dropped.

And here is one with scaling (not really necessary, just for demonstration purposes).

%\documentclass{article}

\documentclass[border=5]{standalone}

\usepackage{tikz}
%\usepackage{xcolor}
%\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri}

\begin{document}
\begin{tikzpicture}[scale=3]
\draw [rounded corners,fill=gray!20] (0,0)--(1,0)--(0.5,1)--cycle;
\end{tikzpicture}
\end{document}


Here I have scaled the figure up to 3 since your figure is too small.

To make a point, see what happens when I scale the figure up by 5 and set rounded corners=10mm.

-
That was surprisingly easy... I tried smaller/bigger numbers and negative numbers, but just removing the number I didnt even consider. Also, thanks for the tip about xcolor, that was news to me! –  Mythio Mar 21 '13 at 11:41
@Mythio See my edit. –  hpesoj626 Mar 21 '13 at 11:42
@Mythio: Setting rounded corners=2mm in your original code will work as well (even without scaling). –  Jake Mar 21 '13 at 11:44
@jake Thanks, been playing around a bit with the numbers and I think I got how it works now. Great help both of you –  Mythio Mar 21 '13 at 12:15
About xcolor. Sometimes it's interesting to use xcolor with special options. In this case, you need to load xcolor before Tikz something like \usepackage[usenames,dvipsnames]{xcolor} –  Alain Matthes Mar 21 '13 at 12:26

With PSTricks.

\documentclass[pstricks,border=3pt]{standalone}
\begin{document}
\begin{pspicture}(-1,0)(1,2)
\pspolygon[linearc=0.1](-1,0)(0,2)(1,0)
\end{pspicture}
\end{document}


## Application:

\documentclass[pstricks,border={1pt 3pt 1pt -1pt}]{standalone}
\begin{document}
\begin{pspicture}(-1,0)(1,2)
\pspolygon[linearc=0.1,fillstyle=solid,fillcolor=orange](-1,0)(0,2)(1,0)
\rput(0,0.85){\psscalebox{5}{!}}
\end{pspicture}
\end{document}

-
I'm guessing the important part here is the linearc=0.1 which creates the rounded corners? –  Mythio Mar 21 '13 at 14:44
@Mythio: You have good intuition! –  In PSTricks we trust Mar 21 '13 at 14:45