8

The following picture produces ugly sharp edges

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[fill=black]
    (-2,1) circle (2pt) node  (tl) {} 
    (0,1) circle (2pt) node  (tc) {} 
    (2,1) circle (2pt) node  (tr) {} 
    (-6,0) circle (2pt) node  (ll) {} 
    (-4,0) circle (2pt) node  (l) {} 
    (4,0) circle (2pt) node  (r) {}
    (6,0) circle (2pt) node  (rr) {};
\draw[draw=orange, fill=orange]
    (-2,-1) circle (2pt) node  (bl) {} 
    (0,-1) circle (2pt) node  (bc) {} 
    (2,-1) circle (2pt) node  (br) {};
\draw[>=latex, ->, thick]
    (l) edge (tl)
    (r) edge (tr);
\draw[>=latex, ->,thin, orange]
    (bl) edge (l)
    (br) edge (r);
\draw[>=latex, <->, thick]
    (ll) edge (l)
    (rr) edge (r)
    (tl) edge (tc)
    (tc) edge (tr);
\draw[>=latex, <->, orange]
    (bl) edge (bc)
    (bc) edge (br);
\path[rounded corners=1cm, draw=gray!70]
    (-1-6,1) -- (2-6,1) -- (4-6,2) -- (8-6,2) --
    (10-6,1) -- (13-6,1) --(13-6,-1) -- (10-6,-1) --
    (8-6,0) -- (4-6,0) -- (2-6,-1) -- (-1-6,-1) -- cycle;
\path[rounded corners=1.5cm, draw=gray!50]
    (-1-6-0.5,1+0.5) -- (2-6,1+0.5) -- (4-6,2+0.5) --
    (8-6,2+0.5) -- (10-6,1+0.5) -- (13-6+0.5,1+0.5) --
    (13-6+0.5,-1-0.5) -- (10-6,-1-0.5) -- (8-6,-2-0.5) --
    (4-6,-2-0.5) -- (2-6,-1-0.5) -- (-1-6-0.5,-1-0.5) -- cycle;
\end{tikzpicture}
\end{center}
\end{document}

Apparantly, rounded corners first calculates the rounded corners, and then joins the endpoints with a straight line segment. the problem disappears if I set rounded corners=1cm for the second curve.

How can I get larder rounded corners without the jagged edges?

enter image description here

5
  • Could someone add a picture of those sharp edges to my question please? Oct 5, 2014 at 0:33
  • Edited. Are you talking about that 4 strange parts on the external curve?
    – Sigur
    Oct 5, 2014 at 0:45
  • 1
    The radius of second path is to big. If you make it smaller, for example 1.2 cm or the same as has inner path, the jagged edges will disappear.
    – Zarko
    Oct 5, 2014 at 1:33
  • @Zarko thanks Zarko, I noticed as much myself, see the last paragraph of my question. Oct 5, 2014 at 1:42
  • If you persist in selected radius and like to preserve the elegance of path construction, that I see only way to change coordinates of outer path. For example first two rows to \path[rounded corners=1.5cm, draw=gray!50] (-1-6-0.5,1+0.5) -- (2-6.5,1+0.5) -- (4-6,2+0.5) -- (8-6,2+0.5) -- (10-5.5,1+0.5) -- (13-6+0.5,1+0.5) -- ...
    – Zarko
    Oct 5, 2014 at 1:55

1 Answer 1

6

1cm is also too big and visible if you zoom enough. But for a limited number of operations(mostly path morphing operations), you can temporarily change the settings as you go by putting thinggs inside a brace pair and giving options to that.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\path[rounded corners=1.5cm, draw=gray!50]
    (-1-6-0.5,1+0.5) -- (2-6,1+0.5) {[rounded corners=0.5cm]-- (4-6,2+0.5)} --
    (8-6,2+0.5) {[rounded corners=0.1cm]-- (10-6,1+0.5)} -- (13-6+0.5,1+0.5) --
    (13-6+0.5,-1-0.5) -- (10-6,-1-0.5) {[rounded corners=0.8cm]--(8-6,-2-0.5)} --
    (4-6,-2-0.5) {[rounded corners=0.8cm]--(2-6,-1-0.5)} --(-1-6-0.5,-1-0.5)-- cycle;
\end{tikzpicture}
\end{document}

enter image description here

1
  • I was unaware one could do that, thank you! Oct 27, 2014 at 22:39

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.