모서리 인식 기능을 갖춘 pgf 경로 장식

모서리 인식 기능을 갖춘 pgf 경로 장식

각 세그먼트에서 시작 부분이 입력 경로의 날카로운 모서리인지 알 수 있는 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

이것이 당신이 원하는 것입니까?

[이거 검색하다가 퍼커스님이 댓글을 남기신 것 같더군요. 이것이 바로 타악기가 염두에 둔 것인지 아닌지는 확실하지 않습니다. 그렇다면 삭제해야 한다고 알려주세요.]

날카로운 모서리

\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}

|- 및 호가 있는 날카로운 모서리

관련 정보