PGF-Pfaddekoration mit Eckenbewusstsein

PGF-Pfaddekoration mit Eckenbewusstsein

Ich versuche, eine PGF-Dekoration zu erstellen, die in jedem Segment erkennen kann, ob sein Anfang eine scharfe Ecke auf dem Eingabepfad ist, aber ich komme nicht dahinter, wie das geht.

Nehmen wir zum Beispiel das folgende MWE. Es schmückt den Pfad mit Kurven. Wenn es eine Ecke erreicht und kein Platz für eine weitere Kurve ist, zeichnet es einfach eine einfache Linie und nach der Ecke eine Kurve. Wie kann ich es schaffen, nach der Ecke eine weitere einfache Linie zu zeichnen und erst dann mit den Kurven zu beginnen?

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

Antwort1

Ist das was du willst?

[Ich sehe, dass percusse einen Kommentar hinterlassen hat, während ich das nachgeschlagen habe. Ich bin mir nicht sicher, ob percusse genau das im Sinn hatte oder nicht. Wenn ja, lassen Sie mich wissen, dass ich das löschen soll.]

scharfe Ecke

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

scharfe Ecken mit |- und Bögen

verwandte Informationen