迷你示例或 MWE

迷你示例或 MWE
  1. 我喜欢在垂直方向上创建颜色变化的“泵符号“在下面的例子中,从黑色变成蓝色,再变成黑色。

  2. 符号本身不应填充颜色。仅应绘制线条。

我的迷你示例不起作用。有什么想法吗?

迷你示例或 MWE

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{fadings} 
\tikzfading[name=fade gradient, top color=black!80,  bottom color=black!80,
middle color=blue!100]
%% Pumpe Symbol
\tikzset{
  pump/.style={
    circle,
    draw,
    thick,
    minimum size=0.5cm,
    path picture={
      \draw [thick] (path picture bounding box.north) -- 
                    (path picture bounding box.east) --
                    (path picture bounding box.south);
      },
  node contents={}
  }
}
%%%
\begin{document}
\begin{tikzpicture}
 \node at (0,0)[
  pump,
  path fading=fade gradient,
  align = left
];
\end{tikzpicture}
\end{document}

答案1

恕我直言,这里你既不需要这个shadings也不需要这个fadings图书馆。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc}
%% Pumpe Symbol
\tikzset{
  pump/.style={
    circle,
    thick,
    minimum size=0.5cm,
    path picture={
      \path[top color=black!80,  bottom color=black!80,
middle color=blue!100,even odd rule] 
([xshift={-0.5pt}]path picture bounding box.north) -- 
                    (path picture bounding box.east) --
                    ([xshift={-0.5pt}]path picture bounding box.south) -- cycle                 
                    ([xshift=0.5pt,yshift={-(1+sqrt(2))*1pt}]path picture bounding box.north) -- 
                    ([xshift={-sqrt(2)*1pt}]path picture bounding box.east) --
                    ([xshift=0.5pt,yshift={(1+sqrt(2))*1pt}]path picture bounding box.south)-- cycle;
      \path[top color=black!80,  bottom color=black!80,
middle color=blue!100,even odd rule] let 
 \p1=($(path picture bounding box.north)-(path picture bounding box.center)$) 
 in (path picture bounding box.center) circle[radius=\y1]
 (path picture bounding box.center) circle[radius=\y1-1pt];                         
      },
  node contents={}
  }
}
%%%
\begin{document}
\begin{tikzpicture}
 \node at (0,0)[
  pump,
  align = left
];
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

使用shadings库而不是fadings,可能会使用以下代码。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{shadings} 
\pgfdeclareverticalshading{rainbow}{100bp}
    {color(0bp)=(black); 
    color(40bp)=(black);
    color(50bp)=(blue);
    color(60bp)=(black); 
    color(100bp)=(black)}


%\tikzfading[name=fade gradient, top color=black!80,  bottom color=black!80,
%middle color=blue!100]
%% Pumpe Symbol
\tikzset{
  pump/.style={
    circle,
    draw,
    thick,
    minimum size=0.5cm,
    path picture={
      \draw [shading=rainbow,thick] (path picture bounding box.north) -- 
                    (path picture bounding box.east) --
                    (path picture bounding box.south);
      },
  node contents={}
  }
}
%%%
\begin{document}
\begin{tikzpicture}
 \node at (0,0)[
  pump,
  %path fading=fade gradient,
  align = left
];
\end{tikzpicture}
\end{document} 

在此处输入图片描述

相关内容