# Combining paths before making them double

I must thank TeX Stack Exchange, especially for these questions:

I could come up with this:

Now the finishing touch to make the badge look like the third image would be to convert all thick lines to double lines (actually, the only thing that really annoys me is that thick circle at the center). But I need to combine the paths first. Is there an easy way to do it in TikZ or should I leave it like this?

Free bonus. I assume there is no way to reduce the letter-spacing within decorations.text?

\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text,decorations.shapes,calc}

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Calibri}

\begin{document}
\thispagestyle{empty}

% Andrew Stacey's workaround for the foreach bug
\makeatletter

\def\tikz@clear@foreach{%
\let\pgffor@beginhook=\pgfutil@empty
\let\pgffor@endhook=\pgfutil@empty
\let\pgffor@afterhook=\pgfutil@empty
}

\def\tikz@plot@expression(#1){%
\edef\tikz@plot@data{\noexpand\tikz@clear@foreach\noexpand\pgfplotfunction{\expandafter\noexpand\tikz@plot@var}{\tikz@plot@samplesat}}%
\expandafter\def\expandafter\tikz@plot@data\expandafter{\tikz@plot@data{\tikz@scan@one@point\pgfutil@firstofone(#1)}}%
\tikz@@@plot%
}
\makeatother

% #1 number of teeths
% #4 angle from start to end of the first arc
% #5 angle to decale the second arc from the first

\newcommand{\gear}[5]{%
\draw[rotate=-4] (0:#2)
\foreach \i in {1,...,#1} {%
{[rotate=(\i-1)*360/#1] -- (0:#2)  arc (0:#4:#2) {
-- (#4+#5:#3)  arc (#4+#5:360/#1-#5:#3)}}
} -- cycle;}

\begin{tikzpicture}[remember picture,overlay]

\tikzstyle{reverseclip}=[insert path={(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)}
]

\begin{pgfinterruptboundingbox} % To make sure our clipping path does not mess up the placement of the picture
% The small disk at center will stay white (first inverse clip selection)
\path[clip] circle (0.715) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}

% Both curves that cut the gear
\draw[line width=2pt] (175:1.33) .. controls +(-5:2) and +(186:0.2) .. (6:2);
\draw[line width=2pt] (185:1.33) .. controls +(-5:2) and +(186:0.2) .. (-9:2);

\begin{pgfinterruptboundingbox}
% The arrow will cover the gear (second inverse clip selection)
\path[clip] (175:1.25) arc (175:185:1.25) .. controls +(-5:2) and +(186:0.2) .. (-7.47:2.1) arc (-7.47:5.1:2.1) .. controls +(186:0.2) and +(-5:2) .. (175:1.33) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}

% The gear, and the smallest circle
\gear{14}{1.05}{1.25}{10.5}{2}
\draw[line width=2pt] circle (0.75);

% Thick circles with the text
\draw[line width=2pt] circle (1.33) circle (2);
\draw[decorate,decoration={shape sep=5mm,text along path,raise=1.5mm,text={|\fontsize{16.5}{16.5}\selectfont|PROLOGIN 2013||}}] (172:1.33) arc (172:8:1.33);

% Arrow tips
\draw[line width=2pt] (10.5:2) .. controls +(-5:0.3) and +(185:0.3) .. (6:3.8) .. controls +(0,-0.2) and +(0.2,0) .. (-20:2);

% Beginning of arrow
\draw[line width=2pt] (168:2) .. controls +(190:0.36) and +(175:0.36) .. (175:2);
\draw[line width=2pt] (162:2) .. controls +(190:0.7) and +(175:0.7) .. (180:2);

\end{tikzpicture}
\end{document}

-
+1: Wow! Nice work! You could post it to TeXample once you have the desired result! :) –  Count Zero Aug 18 '12 at 22:57
I would draw a thinner white line over the thick black lines –  JLDiaz Aug 19 '12 at 9:36
Do you really need to combine the lines? As JLDiaz comments, you could draw the picture twice: once with very thick black lines and once with a thin white one. This is, after all, what the double switch actually does (I presume that's what you mean by "double the lines"). If you really want to combine them, it's certainly possible by saving each path to a macro and then concatenating the macros. –  Loop Space Aug 20 '12 at 14:46

Your paths are too complicated to be combined. Because the actually shown paths are partially defined using clips, the result of combining the paths will not be quite how you want. The point is that clips are not applied when the path is constructed but when it is rendered. So if you save a path to combine it later with another, the clip will not be evident in the saved path.

So to take advantage of the double key to achieve the effect that you want, you will need to define your paths not using clips. But once you have done that, you will most likely find that you can simply put your paths to be combined in a single \draw command and thus combine them at definition time.

An alternative (which I mentioned in my comment) is simply to draw the picture twice, once with a thick black line and once with a thin white line. This is relatively straightforward - here's a modification of your code that does this. As you can see, it needs a little tweaking: the thickness of the lines that I've chosen means that your clips should be slightly modified. To do this, I've split your code in half so that only the bits that should be doubled are doubled (I may have this wrong, of course).

Regarding your "bonus" question, the automaton that decorates paths cannot go backwards, it would seem. So to squeeze letters together it is necessary to stop it going forwards so much. What the automaton does is: measure the next letter, move forward half its length, typeset the letter, move forward half its length, possibly add an extra shift. The extra shift is already at 0pt, so the room for change is in the shifting. What I've done is put in a code that modifies this so that it moves forward X times its length. This might not be the right way to do it but is the simplest.

Here's the code:

\documentclass[11pt]{article}
%\url{http://tex.stackexchange.com/q/67746/86}
\usepackage{tikz}
\usetikzlibrary{decorations.text,decorations.shapes,calc}

\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont[Mapping=tex-text]{Calibri}

\tikzset{
reverseclip/.style={
insert path={(current page.north east) --
(current page.south east) --
(current page.south west) --
(current page.north west) --
(current page.north east)}
}
}

\thispagestyle{empty}

% Andrew Stacey's workaround for the foreach bug
\makeatletter

\def\tikz@clear@foreach{%
\let\pgffor@beginhook=\pgfutil@empty
\let\pgffor@endhook=\pgfutil@empty
\let\pgffor@afterhook=\pgfutil@empty
}

\def\tikz@plot@expression(#1){%
\edef\tikz@plot@data{\noexpand\tikz@clear@foreach\noexpand\pgfplotfunction{\expandafter\noexpand\tikz@plot@var}{\tikz@plot@samplesat}}%
\expandafter\def\expandafter\tikz@plot@data\expandafter{\tikz@plot@data{\tikz@scan@one@point\pgfutil@firstofone(#1)}}%
\tikz@@@plot%
}

\pgfkeys{
/pgf/decoration/squeeze text/.code={%
}
}

% #1 number of teeths
% #4 angle from start to end of the first arc
% #5 angle to decale the second arc from the first

\newcommand{\gear}[5]{%
\draw[rotate=-4] (0:#2)
\foreach \i in {1,...,#1} {%
{[rotate=(\i-1)*360/#1] -- (0:#2)  arc (0:#4:#2) {
-- (#4+#5:#3)  arc (#4+#5:360/#1-#5:#3)}}
} -- cycle;}

\newcommand{\drawlogo}[1]{%
\begin{tikzpicture}[remember picture,overlay,bronze/.style={#1}]
\useasboundingbox (-3,-2.5) rectangle (4,2.5);
\begin{pgfinterruptboundingbox} % To make sure our clipping path does not mess up the placement of the picture
% The small disk at center will stay white (first inverse clip selection)
\path[clip] circle (0.715) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}

% Both curves that cut the gear
\draw[bronze] (175:1.33) .. controls +(-5:2) and +(186:0.2) .. (6:2);
\draw[bronze] (185:1.33) .. controls +(-5:2) and +(186:0.2) .. (-9:2);

\begin{pgfinterruptboundingbox}
% The arrow will cover the gear (second inverse clip selection)
\path[clip] (175:1.25) arc (175:185:1.25) .. controls +(-5:2) and +(186:0.2) .. (-7.47:2.1) arc (-7.47:5.1:2.1) .. controls +(186:0.2) and +(-5:2) .. (175:1.33) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}

% The gear, and the smallest circle
%\gear{14}{1.05}{1.25}{10.5}{2}
\draw[bronze] circle (0.75);

% Thick circles with the text
\draw[bronze] circle (1.33) circle (2);
%\draw[decorate,decoration={shape sep=5mm,text along path,raise=1.5mm,text={|\fontsize{16.5}{16.5}\selectfont|PROLOGIN 2013||}}] (172:1.33) arc (172:8:1.33);

% Arrow tips
\draw[bronze] (10.5:2) .. controls +(-5:0.3) and +(185:0.3) .. (6:3.8) .. controls +(0,-0.2) and +(0.2,0) .. (-20:2);

% Beginning of arrow
\draw[bronze] (168:2) .. controls +(190:0.36) and +(175:0.36) .. (175:2);
\draw[bronze] (162:2) .. controls +(190:0.7) and +(175:0.7) .. (180:2);

\end{tikzpicture}%
}
\newcommand{\decoratelogo}{%
\begin{tikzpicture}[remember picture,overlay]
\useasboundingbox (-3,-2.5) rectangle (4,2.5);
\begin{pgfinterruptboundingbox} % To make sure our clipping path does not mess up the placement of the picture
% The small disk at center will stay white (first inverse clip selection)
\path[clip] circle (0.715) -- cycle [reverseclip];
% The arrow will cover the gear (second inverse clip selection)
\path[clip] (175:1.25) arc (175:185:1.25) .. controls +(-5:2) and +(186:0.2) .. (-7.47:2.1) arc (-7.47:5.1:2.1) .. controls +(186:0.2) and +(-5:2) .. (175:1.33) -- cycle [reverseclip];
\end{pgfinterruptboundingbox}

% The gear
\gear{14}{1.05}{1.25}{10.5}{2}

\draw[decorate,decoration={shape sep=5mm,text along path,squeeze text=.4,raise=1.5mm,text={|\fontsize{16.5}{16.5}\selectfont|PROLOGIN 2013 ||}}] (172:1.33) arc (172:8:1.33);

\end{tikzpicture}%
}

\begin{document}
\drawlogo{line width=6pt,black}%
\drawlogo{line width=2pt,white}%
\decoratelogo
\end{document}


(Other minor changes: shifted definitions to before \begin{document} and changed \tikzstyle to \tikzset)

Result:

I realise that this isn't quite answering the question you actually asked about combining paths. If you really do want to do this by combining paths, then as I said above you will need to change how you define the picture. So if you want a solution that uses combining paths, figure out the redefinition and edit the question accordingly.

I hope that what I've done gives you enough to get to the next step with your drawing.

-