
特に以下の質問については、TeX Stack Exchange に感謝します。
私はこれを思いつきました:
バッジを 3 番目の画像のように見せるための最後の仕上げは、すべての太い線を二重線に変換することです (実際、私を本当に悩ませているのは、中央の太い円だけです)。ただし、最初にパスを結合する必要があります。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
必要な効果を得るには、クリップを使用せずにパスを定義する必要があります。ただし、これを実行したら、結合するパスを 1 つの\draw
コマンドにまとめて、定義時に結合できることがわかるでしょう。
別の方法 (コメントで言及しました) は、画像を 2 回描画することです。1 回は太い黒線で、もう 1 回は細い白線で描画します。これは比較的簡単です。これを実行するコードの変更を以下に示します。ご覧のとおり、少し調整が必要です。選択した線の太さにより、クリップを少し変更する必要があります。これを行うために、コードを半分に分割して、2 倍にする必要がある部分のみが 2 倍になるようにしました (もちろん、間違っている可能性があります)。
あなたの「おまけ」の質問に関してですが、パスを装飾するオートマトンでは、後戻りできないようです。文字を詰め込むには、オートマトンがあまり前に進まないようにする必要があります。オートマトンが行うことは、次の文字を測定し、その長さの半分を前に進め、文字をタイプセットし、その長さの半分を前に進め、場合によってはシフトを追加します。追加のシフトはすでに 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
)
結果:
これは、パスの結合について実際に尋ねられた質問に完全には答えていないことに気づきました。パスの結合によってこれを本当に実行したい場合は、上で述べたように、画像の定義方法を変更する必要があります。したがって、パスの結合を使用するソリューションが必要な場合は、再定義を理解し、それに応じて質問を編集してください。
私がやったことが、あなたの絵を描く次のステップに進むのに十分な助けになれば幸いです。