各セグメントの開始が入力パス上の鋭角な角であるかどうかを判断できる pgf デコレーションを作成しようとしていますが、その方法がわかりません。
たとえば、次の MWE を見てみましょう。これはパスを曲線で装飾します。角に到達し、別の曲線を描く余地がない場合は、単純な線を描き、角の後に曲線を描きます。角の後に別の単純な線を描き、その後に曲線を開始するようにするにはどうすればよいでしょうか。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}
\pgfdeclaredecoration{examp}{A}
{
\state{A}[width=4mm,auto corner on length=4mm]
{
\pgfpathcurveto{\pgfpoint{0mm}{0}}{\pgfpoint{2mm}{5mm}}{\pgfpoint{4mm}{0}};
}
%
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast};
}
}
\begin{document}
\begin{tikzpicture}
\draw[decoration={examp,path has corners=true},decorate] (0,0) -- (0,3) -- (3,3);
\end{tikzpicture}
\end{document}
答え1
これは、あなたの望むことですか?
[私がこれを調べていたときに、percusse がコメントを残していたのがわかりました。これが percusse が考えていたものとまったく同じかどうかはわかりません。もしそうなら、これを削除するように私に知らせてください。]
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}
\newlength{\prelength}
\pgfdeclaredecoration{examp}{A}
{
\state{A}
[
width=4mm,
switch if input segment less than={4mm to B},
]
{
\pgfpathcurveto{\pgfpoint{0mm}{0}}{\pgfpoint{2mm}{5mm}}{\pgfpoint{4mm}{0}};
}
\state{B}
[
width=\pgfdecoratedinputsegmentremainingdistance,
repeat state=0,
next state=C,
persistent precomputation={%
\setlength{\prelength}{\pgfdecoratedinputsegmentremainingdistance}
},
]
{
\pgflineto{\pgfpointdecoratedinputsegmentlast};
}
\state{C}
[
width=\prelength,
repeat state=0,
next state=A,
]
{
\pgflineto{\pgfpoint{\prelength}{0}};
}
\state{final}
{
\pgfpathlineto{\pgfpointdecoratedpathlast};
}
}
\begin{document}
\begin{tikzpicture}
\draw[decoration={examp},decorate] (0,0) -- (0,3) -- (3,3) |- cycle;
\draw[decoration={examp},decorate, xshift=40mm] (0,0) -- (0,3) -- (3,3) arc (90:-90:1.5) [out=135, in=45] to cycle;
\end{tikzpicture}
\end{document}