1

I'm trying to draw an outline of a shape, combined from primitives (circles and a rectangle). I'm using the Caramdir's code from here but it doesn't work for some reason.

My code:

\documentclass[12pt, border=0.5mm]{standalone}
\usepackage{graphicx}

\usepackage[ngerman]{babel}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
    \draw[line width=0.05mm, postaction={gray!10, fill}] 
            (-3, -0.4) rectangle (11.5, 0.4)
            (-3, 0) circle (0.55mm)                         
            (7.2, 0) circle (1.5mm)
            (7.2, 0) circle (1.1mm)
            (0, 0) circle (0.95mm);
    \end{tikzpicture}
\end{document}

complex shape

The outline I need is:

outline

georgmierau
  • 1,588
  • What are you trying to accomplish with the two concentric circles? Do you want the space between them to be filled (and not the inner circle)? – John Kormylo Sep 23 '15 at 22:40
  • John Kormylo, it has to be a hole. – georgmierau Sep 23 '15 at 22:54
  • Please can you post complete code i.e. make it so we can compile it? A complete, small example is much more useful than a mere fragment. – cfr Sep 23 '15 at 23:02

2 Answers2

3

One way, though seeing the other answer, maybe this is not what you want:

\documentclass[tikz,border=10pt]{standalone}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm, line width=.05mm]
  \clip (-4.5,-2) rectangle (14.5,2) (7.2,0) circle (1.05);
  \draw [double distance=.8mm, double=gray!10, postaction={fill=gray!10}]
    (-3,0) circle (.55mm)
    -- (0,0) circle (.95mm)
    -- (7.2,0) circle (1.5mm)
    -- (11.5,0);
  \draw (7.2,0) circle (1.1mm) (11.5,.4) -- (11.5,-.4);
\end{tikzpicture}
\end{document}

hole

cfr
  • 198,882
1

The order in which things need to be drawn and filled can become complicated, depending on what you want covered. I used regular gray so I could seen it more easily.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=1mm, y=1mm]
    \path[draw=black,line width=0.05mm]
        (-3, 0) circle (0.55mm)
        (0, 0) circle (0.95mm)
        (7.2, 0) circle (1.5mm);
    \path[draw=black,line width=0.05mm,fill=gray] 
        (-3, -0.4) rectangle (11.5, 0.4);
    \path[fill=gray]% note reduction in radius by 1/2 line width
        (7.2, 0) circle (1.475mm)
        (-3, 0) circle (0.525mm)
        (0, 0) circle (0.925mm);
    \path[draw=black,line width=0.05mm,fill=white]
        (7.2, 0) circle (1.1mm);
\end{tikzpicture}
\end{document}

complex outline

John Kormylo
  • 79,712
  • 3
  • 50
  • 120