
Я должен поблагодарить TeX Stack Exchange, особенно за эти вопросы:
- Создание шестеренок в TikZ
- Как инвертировать выделение «клипа» в TikZ?
- Как использовать plot в цикле foreach в один путь?
Я мог бы придумать следующее:
Теперь последний штрих, чтобы значок выглядел как на третьем изображении, — это преобразование всех толстых линий в двойные (на самом деле, единственное, что меня действительно раздражает, это толстый круг в центре). Но сначала мне нужно объединить контуры. Есть ли простой способ сделать это в TikZ или мне оставить все как есть?
Бесплатный бонус.Я полагаю, что нет возможности уменьшить межбуквенный интервал внутри 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
% #2 radius intern
% #3 radius extern
% #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
Ваши пути слишком сложны для объединения. Поскольку фактически показанные пути частично определены с помощью клипов, результат объединения путей будет не совсем таким, как вы хотите. Дело в том, что клипы применяются не при построении пути, а при его рендеринге. Поэтому если вы сохраните путь, чтобы объединить его позже с другим, клип не будет виден в сохраненном пути.
Итак, чтобы воспользоваться ключом double
для достижения желаемого эффекта, вам нужно будет определить свои пути, не используя клипы. Но как только вы это сделаете, вы, скорее всего, обнаружите, что можете просто объединить свои пути в одной \draw
команде и таким образом объединить их во время определения.
Альтернатива (которую я упомянул в своем комментарии) — просто нарисовать картинку дважды, один раз толстой черной линией и один раз тонкой белой. Это относительно просто — вот модификация вашего кода, которая это делает. Как вы видите, ее нужно немного подправить: толщина линий, которую я выбрал, означает, что ваши клипы должны быть немного изменены. Для этого я разделил ваш код пополам, так что удваиваются только те биты, которые должны быть удвоены (конечно, я могу ошибаться).
Что касается вашего "бонусного" вопроса, автомат, который украшает пути, похоже, не может идти назад. Поэтому, чтобы сжать буквы вместе, необходимо остановить его движение вперед так сильно. Что делает автомат: измеряет следующую букву, движется вперед на половину ее длины, набирает букву, движется вперед на половину ее длины, возможно, добавляет дополнительный сдвиг. Дополнительный сдвиг уже на 0pt, поэтому место для изменения находится в сдвиге. То, что я сделал, это вставил код, который изменяет это так, чтобы он двигался впередИксумножить на его длину. Это может быть не совсем правильный способ, но это самый простой.
Вот код:
\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={%
\expandafter\g@addto@macro\csname pgf@decorate@@text along path@after typeset@options\endcsname{,width=+#1\wd\pgf@lib@dec@text@box}%
\expandafter\g@addto@macro\csname pgf@decorate@@text along path@before typeset@options\endcsname{,width=+#1\wd\pgf@lib@dec@text@box}%
}
}
% #1 number of teeths
% #2 radius intern
% #3 radius extern
% #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}
(Другие незначительные изменения: определения смещены на «до» \begin{document}
и изменены \tikzstyle
на « \tikzset
»)
Результат:
Я понимаю, что это не совсем ответ на вопрос, который вы на самом деле задали о комбинировании путей. Если вы действительно хотите сделать это, комбинированием путей, то, как я сказал выше, вам нужно будет изменить то, как вы определяете изображение. Так что если вам нужно решение, которое использует комбинирование путей, разберитесь с переопределением и отредактируйте вопрос соответствующим образом.
Надеюсь, то, что я сделал, даст вам достаточно информации, чтобы перейти к следующему этапу вашего рисунка.