2

I need to draw a closed shape using controls and then round the heads. The problem is the starting point (The upper one) is not rounded as if the shape is not closed, and the cycle command is not working correctly.

Here is my code:

\documentclass[margin=10mm]{standalone}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}

        \draw[rounded corners = 50pt, fill=red] (0,5) .. controls(0.2,1) .. (10,0) ..controls (0.2,-1) ..(0,-5).. controls(-0.2,-1)..(-10,0)..controls(-0.2,1)..(0,5);

    \end{tikzpicture}
\end{document}

enter image description here I want to know why this is happening?

  • Welcome to TeX.SX! Why don't you just add another .. controls() .. (0, 5) that leads you back to your end point? – Timm Apr 6 '17 at 8:50
  • @Timm I tried this and the output is weird – Safwat Alshazly Apr 6 '17 at 8:55
  • I saw the problem, and tried playing with it, but could not really find a solution.. however, have a look at this and this, it might help you with your control points. However, I don't really understand this right now, when I apply the style defined there your example does not work like theirs. – Timm Apr 6 '17 at 9:33
1

Not a real solution, but the following workaround may be acceptable. I used line width = 4pt, line join = round, red and cycle for the last point to give the effect of rounded corners = 50pt.

\documentclass[margin=10mm]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[line width=4pt, line join=round, red]
\draw [fill=red] (0,5) .. controls(0.2,1) .. (10,0) ..controls (0.2,-1) ..(0,-5).. controls(-0.2,-1)..(-10,0) .. controls(-0.2,1).. cycle;
\end{tikzpicture}

\end{document}

enter image description here

  • I do not think that is a 50pt rounded corner. This is what 50pt should be i.stack.imgur.com/jVBs9.png. – Symbol 1 Apr 6 '17 at 12:24
  • @Symbol1: Yes, that large 50pt is the real source of the problem, so I tried to preserve the shape the OP wanted using thick lines. – AboAmmar Apr 6 '17 at 12:40
  • @Symbol1 Almost what I wanted! Good idea – Safwat Alshazly Apr 8 '17 at 8:28

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.