褪色和图片问题

褪色和图片问题

我尝试生成多个副本褪色的文字使用PG 3.0 图片功能但放置出现了问题。只绘制了原点的那个。

以下是我所做的:

\documentclass[varwidth,margin=5mm]{standalone} 
\usepackage{tikz}
\usetikzlibrary{fadings}

\tikzset{
   myPic/.pic={
  \begin{tikzfadingfrompicture}[name = fading letter]
    \node[text = transparent!0, inner xsep = 0pt, outer xsep = 0pt] {test text};
  \end{tikzfadingfrompicture}
    \node[inner sep = 0pt, outer sep = 0pt] (textnode) {\phantom{test text}}; 
    \shade[path fading = fading letter, left color = blue, right color = green, fit fading = false, opacity=0.5] (textnode.south west) rectangle (textnode.north east);% 
   }
}

\begin{document} 
\begin{tikzpicture}
  \pic at (0,0)    {myPic};

  \pic at (0,2)    {myPic};
\end{tikzpicture}
\end{document}

非常欢迎任何能够解决该问题的帮助。

答案1

您还需要使用 来改变淡入淡出效果fading transform。我添加了

fading transform={shift={(textnode)}}

要得到

\documentclass[varwidth,margin=5mm]{standalone} 
\usepackage{tikz}
\usetikzlibrary{fadings}

\tikzset{
   myPic/.pic={
  \begin{tikzfadingfrompicture}[name = fading letter]
    \node[text = transparent!0, inner xsep = 0pt, outer xsep = 0pt] {test text};
  \end{tikzfadingfrompicture}
    \node[inner sep = 0pt, outer sep = 0pt] (textnode) {\phantom{test text}}; 
    \shade[path fading = fading letter, left color = blue,
     right color = green, fit fading = false, opacity=0.5,
     fading transform={shift={(textnode)}}] (textnode.south west) rectangle (textnode.north east);% 
   }
}

\begin{document} 
\begin{tikzpicture}
  \pic at (0,0)    {myPic};

  \pic at (0,2)    {myPic};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容