Eine Linie in Tikz ausblenden

Eine Linie in Tikz ausblenden

Ich beginne mit dem folgenden Code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, matrix}

\begin{document}

\begin{tikzpicture}[description/.style={fill=white,inner sep=1.5pt}]
  \matrix (m) [%
    matrix of math nodes,
    row sep=8em, column sep=8em,
    text height=1.5ex,
    text depth=0.25ex
  ]{
    (a \rightarrow t) \rightarrow t & a & (a \rightarrow S b) \rightarrow S b
    \\
    & S a &
    \\
  };
  \path[-stealth,font=\scriptsize, red]
    (m-1-2) edge node[description] {LIFT$_t$} (m-1-1)
    (m-2-2) edge node[sloped,description] {A} (m-1-1);
  \path[-stealth,font=\scriptsize, blue]
    (m-1-2) edge node[description] {LIFT$_{S b}$} (m-1-3)
    (m-2-2) edge node[sloped,description] {BIND} (m-1-3);
  \path[-stealth,font=\scriptsize, magenta]
    (m-1-2) edge node[description] {$\eta$} (m-2-2);
  \path[-stealth,font=\scriptsize%, left color=red, right color=blue
    ]
    (m-1-1) edge[bend left=25] node[pos=.75,sloped,description]
    {Cresti's [+WH]} (m-1-3);
\end{tikzpicture}

\end{document}

Ich bin daran interessiert, die geschwungene Linie (die letzte \pathim Beispiel) von Rot über Magenta nach Blau zu schattieren (ich habe die anderen eingeschlossen, \pathdamit Sie sehen, warum ich daran interessiert sein könnte).

Der auskommentierte Teil zeigt meine beste Vermutung, wie das funktionieren würde, aber das ist natürlich nicht der Fall. Ich habe einige Zeit damit verbracht, TeX.SX zu durchsuchen, und habe einige Lösungen gesehen, die ähnlich aussehen, aber nichts, das das Problem direkt anzugehen scheint.

Antwort1

Vielleicht habe ich zu früh gesprochen.

Mark Wibrows Lösungscheint zuzutreffen.

Die Ausgabe

Bildbeschreibung hier eingeben

Marks Code angewendet

\documentclass[border=0.125cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings,decorations.pathmorphing,arrows.meta,matrix,calc}


\makeatletter
% Code by Mark Wibrow 
% https://tex.stackexchange.com/a/137438/116936
% solution 2
\newif\iftikz@shading@path

\tikzset{
    % There are three circumstances in which the fading sep is needed:
    % 1. Arrows which do not update the bounding box (which is most of them).
    % 2. Line caps/joins and mitres that extend outside the natural bounding 
    %    box of the path (these are not calculated by PGF).
    % 3. Other reasons that haven't been anticipated.
    fading xsep/.store in=\pgfpathfadingxsep,
    fading ysep/.store in=\pgfpathfadingysep,
    fading sep/.style={fading xsep=#1, fading ysep=#1},
    fading sep=0.0cm,
    shading path/.code={%
        % Prevent this stuff happning recursively.
        \iftikz@shading@path%
        \else%
            \tikz@shading@pathtrue%
            % \tikz@addmode installs the `modes' (e.g., fill, draw, shade) 
            % to be applied to the path. It isn't usualy for doing more
            % changes to the path's construction.
            \tikz@addmode{%
                \pgfgetpath\pgf@currentfadingpath%
                % Get the boudning box of the current path size including the fading sep
                \pgfextract@process\pgf@fadingpath@southwest{\pgfpointadd{\pgfqpoint{\pgf@pathminx}{\pgf@pathminy}}%
                    {\pgfpoint{-\pgfpathfadingxsep}{-\pgfpathfadingysep}}}%%
                \pgfextract@process\pgf@fadingpath@northeast{\pgfpointadd{\pgfqpoint{\pgf@pathmaxx}{\pgf@pathmaxy}}%
                    {\pgfpoint{\pgfpathfadingxsep}{\pgfpathfadingysep}}}%
                % Clear the path
                \pgfsetpath\pgfutil@empty%                          
                % Interrupt the path and picture to create a fading.
                \pgfinterruptpath%
                \pgfinterruptpicture%
                    \begin{tikzfadingfrompicture}[name=.]
                        \path [shade=none,fill=none, #1] \pgfextra{%
                            % Set the softpath. Any transformations in #1 will have no effect.
                            % This will *not* update the bounding box...
                            \pgfsetpath\pgf@currentfadingpath%
                            % ...so it is done manually.
                            \pgf@fadingpath@southwest
                            \expandafter\pgf@protocolsizes{\the\pgf@x}{\the\pgf@y}%
                            \pgf@fadingpath@northeast%
                            \expandafter\pgf@protocolsizes{\the\pgf@x}{\the\pgf@y}%
                        };
                        % Now get the bounding of the picture.
                        \xdef\pgf@fadingboundingbox@southwest{\noexpand\pgfqpoint{\the\pgf@picminx}{\the\pgf@picminy}}%
                        \xdef\pgf@fadingboundingbox@northeast{\noexpand\pgfqpoint{\the\pgf@picmaxx}{\the\pgf@picmaxy}}%
                        %
                    \end{tikzfadingfrompicture}%
                \endpgfinterruptpicture%
                \endpgfinterruptpath%
                % Install a rectangle that covers the shaded/faded path picture.                                
                \pgfpathrectanglecorners{\pgf@fadingboundingbox@southwest}{\pgf@fadingboundingbox@northeast}%
                % Make the fading happen.
                \def\tikz@path@fading{.}%
                \tikz@mode@fade@pathtrue%
                \tikz@fade@adjustfalse%10pt
                % Shift the fading to the mid point of the rectangle
                \pgfpointscale{0.5}{\pgfpointadd{\pgf@fadingboundingbox@southwest}{\pgf@fadingboundingbox@northeast}}%
                \edef\tikz@fade@transform{shift={(\the\pgf@x,\the\pgf@y)}}%
            }%
        \fi%
    }
}

\begin{document}
\begin{tikzpicture}[description/.style={fill=white,inner sep=1.5pt}]
  \matrix (m) 
    [%
      matrix of math nodes,
      row sep=8em, column sep=8em,
      text height=1.5ex,
      text depth=0.25ex
    ]
    {
    (a \rightarrow t) \rightarrow t & a   & (a \rightarrow S b) \rightarrow S b \\
                                    & S a &                                     \\
  };
  \path[-stealth,font=\scriptsize, red]
    (m-1-2) edge node[description] {LIFT$_t$} (m-1-1)
    (m-2-2) edge node[sloped,description] {A} (m-1-1);
  \path[-stealth,font=\scriptsize, blue]
    (m-1-2) edge node[description] {LIFT$_{S b}$} (m-1-3)
    (m-2-2) edge node[sloped,description] {BIND} (m-1-3);
  \path[-stealth,font=\scriptsize, magenta]
    (m-1-2) edge node[description] {$\eta$} (m-2-2);
    \def\height{2}
  \path
    [
    left color=red,
    right color=blue,
    shading path={draw=transparent!0,stealth-stealth,},
    ]
    (m-1-1) .. controls ($(m-1-1)!.3!(m-1-3)+(0,\height)$) and ($(m-1-1)!.7!(m-1-3)+(0,\height)$) .. (m-1-3) ;
    %and now for the label
    \path (m-1-1) .. controls ($(m-1-1)!.3!(m-1-3)+(0,\height)$) and ($(m-1-1)!.7!(m-1-3)+(0,\height)$) .. (m-1-3) node [pos=.7,sloped, fill = white, font=\scriptsize, yshift=-1pt ] {Cresti's [+WH]} ; 
\end{tikzpicture}
\end{document}

verwandte Informationen