4

I would like to draw a smoothly rounded figure in TikZ as below, but with simpler (and easier to modify) code. I mean without hand calculating good tangents for the curve at all vertices. That would make it easier to do less symmetric triangles, and other polygons.

Note that unlike the question

Drawing a triangle with rounded corners in TikZ

I want the outline to curve in and out to make bulges.

I wonder if the rounded corners option will let me do this by drawing a hexagon with alternate vertices closer and farther from the center. My attempts so far have failed, for reasons that the TikZ and PGF Manual describes on p. 587. Even when I make the curve of the corners very small the lines ''suddenly extend over the other end" which looks terrible. This may just be more than the option can be expected to do.

But is there a way to do it?

\documentclass{amsart}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
      \draw (0,3.5) 
      to [out=0,in=120]  (1.5,2.7)
      to [out=-60,in=50] (3,0)
      to [out=-130,in=0] (0,.05)
      to [out=180,in=-50] (-3,0)
      to [out=130,in=-120] (-1.5,2.7)
      to [out=60,in=180] (0,3.5);
    \end{tikzpicture}
\end{document}

enter image description here

  • Could you add an image detailing your problem? I'm sort of at a loss what exactly your problem is. – Timm Mar 8 '17 at 16:26
  • 1
    Edit your question and than click on the "add image" icon you'll find near the {} icon. Then click up the popup to upload the image from your machine. – CarLaTeX Mar 8 '17 at 16:49
  • @CarLaTeX Thanks, I had only tried to drag and drop, which did not work for me. – Colin McLarty Mar 8 '17 at 16:52
5

A simple way (same idea as here: Tikz Macro with list of arguments and subroutine calculation)

\documentclass{amsart}
\usepackage{tikz}

\begin{document}

    \tikzset{
        bulging/.style 2 args={
            every to/.style={bend left=#1},
            preaction={
                  fill,draw,join=round,line width=#2+1},
            white,fill,draw,join=round,line width=#2,
        },
    }

    \tikz\draw[bulging={20}{60}](0,0)to(3,0)to(2,2)to cycle;
    %
    \hfill
    %
    \tikz\draw[bulging={40}{50}](0,0)to(3,0)to(4,2)to(2,5)to(-1,3)tocycle;

    \vfill

    \tikz\draw[bulging={50}{50}](0,0)to(4,0)to(6,2)to(7,4)to(5,8)to(1,8)to(-1,5)tocycle;

\end{document}

  • 1
    This works nicely. But one disadvantage is that it will not scale correctly when you use a format like \tikz\draw[scale=.5,bulging={40}{50}] – Colin McLarty Mar 9 '17 at 21:42
  • It also does not work with styles like pattern=north west lines or dashed. – Joe Corneli Aug 17 '17 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.