fade-no-fill.sty 的问题

fade-no-fill.sty 的问题

我正在尝试在路径上使用颜色渐变,并发现了 fade-no-fill.sty,最新版本似乎是https://tex.stackexchange.com/a/567029/56823。它运行得很好,但我有两个小问题。

我的 MWE 如下:

\documentclass[tikz]{standalone}

\usepackage{fade-no-fill}
\usetikzlibrary{shapes}

\begin{document}
\begin{tikzpicture}
    \pgfmathsetmacro{\l}{3}
    \node [red,draw,thick,ellipse] (S) at (-\l,0) {Solide};
    \node [blue,draw,thick,ellipse] (L) at (\l,0) {Liquide};
    \node [green,draw,thick,ellipse] (G) at (0,{\l*sqrt(3)}) {Gaz};
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{bottom color=red,top color=green}] (S) to[bend left] (G);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{top color=green,bottom color=blue}] (G) to[bend left] (L);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{right color=blue,left color=red}] (L) to[bend left] (S);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{left color=red,right color=blue}] (S) to (L);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{top color=green,bottom color=blue}] (L) to (G);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{bottom color=red,top color=green}] (G) to (S);
\end{tikzpicture}
\end{document}

它产生了这个: MWE 输出 笔记:

  1. “Liquide”上方的蓝色箭头。
  2. “Liquide”左边的箭头非常奇怪。

知道是什么原因造成这种情况以及如何解决吗?

答案1

> = latex是没有边界框的箭头。(此箭头在 中定义,pgfcorearrows.code.tex 无论是否arrows.meta包含 均可用。)

使用> = Latex,箭头尖端有一个边界框。(此箭头在 中定义,arrows.meta并带有适当的边界框。)

答案2

这是另一种方法,其中所有箭头都用两种不同的颜色path fading从不同方向绘制两次。

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{shapes, fadings}
\begin{document}
\begin{tikzpicture}
\node[red,draw,thick,ellipse] (S) at (-3,0) {Solide};
\node[blue,draw,thick,ellipse] (L) at (3,0) {Liquide};
\node[green,draw,thick,ellipse] (G) at (0,{3*sqrt(3)}) {Gaz};
\draw[green, path fading=south, thick ,-latex] (S) to[bend left] (G);
\draw[red, path fading=north, thick ,-latex] (S) to[bend left] (G);
\draw[green, path fading=south, thick ,-latex] (G) to[bend left] (L);
\draw[blue, path fading=north, thick ,-latex] (G) to[bend left] (L);
\draw[blue, path fading=west, thick ,-latex] (L) to[bend left] (S);
\draw[red, path fading=east, thick ,-latex] (L) to[bend left] (S);
\draw[blue, path fading=west, thick, shorten >=5pt] (S) to (L); %this arror is problematic
\draw[blue, thick ,-latex] ([xshift=-4pt] L.west) -- (L.west); %seperate arrow head
\draw[red, path fading=east, thick ,-latex] (S) to (L);
\draw[green, path fading=south, thick ,-latex] (L) to (G);
\draw[blue, path fading=north, thick ,-latex] (L) to (G);
\draw[green, path fading=south, thick ,-latex] (G) to (S);
\draw[red, path fading=north, thick ,-latex] (G) to (S);
\end{tikzpicture}
\end{document}

带有颜色渐变箭头的图表

水平蓝色箭头被剪掉,但被重新绘制。更通用的方法是:https://tex.stackexchange.com/a/597939/8650

编辑:

双重绘制可以制成一种风格,从postaction这里开始:

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{fadings, calc}
\begin{document}
\begin{tikzpicture}   
\foreach \a in {0,10,...,360}{
\coordinate (A) at (0,0);
\coordinate (B) at (\a:3);
\draw let \p1=($(B)-(A)$), \n1={atan2(\y1,\x1)} in [green, path fading=west, fading angle = \n1, thick ,-latex, postaction={draw, red, path fading=east, fading angle = \n1, thick ,-latex}]  ([xshift=5pt, yshift=5pt]A) (A) to[bend left] (B);
}
\end{tikzpicture}
\end{document}

红色和绿色箭头轮

答案3

由于我们正在尝试解决方法,我尝试了这个:

\documentclass[tikz]{standalone}

\usepackage{fade-no-fill}
\usetikzlibrary{shapes}

\begin{document}
\begin{tikzpicture}
    \pgfmathsetmacro{\l}{3}
    \node [red,draw,thick,ellipse] (S) at (-\l,0) {Solide};
    \node [blue,draw,thick,ellipse] (L) at (\l,0) {Liquide};
    \node [green,draw,thick,ellipse] (G) at (0,{\l*sqrt(3)}) {Gaz};
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{bottom color=red,top color=green}] (S) to[bend left] (G);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{top color=green,bottom color=blue}] (G) to[bend left] (L);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{right color=blue,left color=red}] (L) to[bend left] (S);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{left color=red,right color=blue}] (S) to (L);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{top color=green,bottom color=blue}] (L) to (G);
    \path [fade path but don't fill={thick,->,>=latex,transparent!0}{bottom color=red,top color=green}] (G) to (S);
    \draw [thick,<-,>=latex,blue] (L.west) -- ++(-0.1,0); % Redraw west arrow
    \draw [thick,<-,>=latex,blue] (L.north) -- ++(0,0.1); % Redraw north arrow
\end{tikzpicture}
\end{document}

解决方法的结果 结果很适合我,但这仍然是一种解决方法。

答案4

我不知道\usepackage{fade-no-fill},但这里有一个替代解决方案tikzfadingfrompicture

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{shapes, fadings, shadings}
\begin{tikzfadingfrompicture}[name=myfading]
\pgfmathsetmacro{\l}{3}
\node[transparent!0,draw,thick,ellipse] (S) at (-\l,0) {Solide};
\node[transparent!0,draw,thick,ellipse] (L) at (\l,0) {Liquide};
\node[transparent!0,draw,thick,ellipse] (G) at (0,{\l*sqrt(3)}) {Gaz};
\draw[transparent!0, thick ,-latex] (S) to[bend left] (G);
\draw[transparent!0, thick ,-latex] (G) to[bend left] (L);
\draw[transparent!0, thick ,-latex] (L) to[bend left] (S);
\draw[transparent!0, thick ,-latex] (S) to (L);
\draw[transparent!0, thick ,-latex] (L) to (G);
\draw[transparent!0, thick ,-latex] (G) to (S);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\draw[lower left=red, lower right=blue, upper left=green, upper right=green, path fading=myfading, fit fading=false] (-3.9,-3.3) rectangle (4.1,3.5);
\end{tikzpicture}
\end{document}

带有颜色褪色箭头的三个节点

编辑:

我刚刚想到了如何防止翻译tikzfadingfrompicture- 只需添加一个包含所有内容的circle中心即可(0,0)

\draw[transparent!100] (0,0) circle (6);。如果需要的话,现在node可以将 s 绘制在淡入淡出之外:

相同的图表,但具有单色节点

\documentclass[tikz, border=1 cm]{standalone}
\usetikzlibrary{shapes, fadings, shadings}
\begin{tikzfadingfrompicture}[name=myfading]
\node[transparent!100,draw,thick,ellipse] (S) at (-3,0) {Solide};
\node[transparent!100,draw,thick,ellipse] (L) at (3,0) {Liquide};
\node[transparent!100,draw,thick,ellipse] (G) at (0,{3*sqrt(3)}) {Gaz};
\draw[transparent!0, thick ,-latex] (S) to[bend left] (G);
\draw[transparent!0, thick ,-latex] (G) to[bend left] (L);
\draw[transparent!0, thick ,-latex] (L) to[bend left] (S);
\draw[transparent!0, thick ,-latex] (S) to (L);
\draw[transparent!0, thick ,-latex] (L) to (G);
\draw[transparent!0, thick ,-latex] (G) to (S);
\draw[transparent!100] (0,0) circle (6);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\draw[lower left=red, lower right=blue, upper left=green, upper right=green, path fading=myfading, fit fading=false] (-4,-1.2) rectangle (4.1,5.8);
\node[red,draw,thick,ellipse] (S) at (-3,0) {Solide};
\node[blue,draw,thick,ellipse] (L) at (3,0) {Liquide};
\node[green,draw,thick,ellipse] (G) at (0,{3*sqrt(3)}) {Gaz};
\end{tikzpicture}
\end{document}

相关内容