如何添加闪亮效果

如何添加闪亮效果

我有以下代码:

\begin{tikzpicture}[decoration={random steps,segment length=8pt,amplitude=4pt},thick]

  \begin{scope}[opacity=.8,transparency group]
    \draw[fill=yellow,draw=none] (-4,3.75) rectangle (4,3);
    \draw[fill=yellow,draw=none,opacity=0.8] (-3.8,3.2) rectangle (3.84,2);
  \end{scope}
  \node[anchor=west] at (4.5,3.5) {hv};
  \draw[dash pattern=on 20pt off 10pt,line width=30pt,draw=white] (-4,2.5) -- (4,2.5);
  \draw[dash pattern=on 20pt off 10pt,line width=2pt] (-4,3) -- (4,3);
  \node[anchor=west] at (4.5,3) {Mask};
  \filldraw[fill=blue!20]
    (4,1.5)
    decorate { -- (4,2) }
    -- (-4,2)
    decorate { -- (-4,1.5) };
  \node[anchor=west] at (4.5,1.75) {Hydrogel};
  \filldraw[fill=orange] 
    (-4,0) -- (4,0)
    decorate { -- (4,1.5) }
    -- (-4,1.5)
    decorate { -- (-4,0) };
  \node[anchor=west] at (4.5,0.75) {Substrat};
\end{tikzpicture}

得到如下图像:

在此处输入图片描述

现在我想为 hv 添加闪亮效果,如模糊轮廓。如何实现?

答案1

一个想法是使用path fading。例如,我path fading = south在水凝胶中使用。代码是

\documentclass[11pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}%<--------You sould add this to your preamble
\usetikzlibrary{%<-----------You should add this to your preamble
    calc,%
    fadings,%
shadings%
}
\listfiles
\begin{document}

\begin{tikzpicture}[decoration={random steps,segment length=8pt,amplitude=4pt},thick]

  \begin{scope}[opacity=.8,transparency group]
    \draw[fill=yellow,draw=none] (-4,3.75) rectangle (4,3);
    \draw[fill=yellow,draw=none,opacity=0.8] (-3.8,3.2) rectangle (3.84,2);
  \end{scope}
  \node[anchor=west] at (4.5,3.5) {hv};
  \draw[dash pattern=on 20pt off 10pt,line width=30pt,draw=white] (-4,2.5) -- (4,2.5);
  \draw[dash pattern=on 20pt off 10pt,line width=2pt] (-4,3) -- (4,3);
  \node[anchor=west] at (4.5,3) {Mask};
  \filldraw[fill=blue!20, path fading=south]%<---------Here I added 'path fading=south'
    (4,1.5)
    decorate { -- (4,2) }
    -- (-4,2)
    decorate { -- (-4,1.5) };
  \node[anchor=west] at (4.5,1.75) {Hydrogel};
  \filldraw[fill=orange] 
    (-4,0) -- (4,0)
    decorate { -- (4,1.5) }
    -- (-4,1.5)
    decorate { -- (-4,0) };
  \node[anchor=west] at (4.5,0.75) {Substrat};
\end{tikzpicture}

\end{document}

输出为

或者如果你喜欢 HV 有光泽,试试这个

\begin{tikzpicture}[decoration={random steps,segment length=8pt,amplitude=4pt},thick]

  \begin{scope}[opacity=.8,transparency group]
    \draw[fill=yellow,draw=none, path fading=south] (-4,3.75) rectangle (4,3);%<-------
    \draw[fill=yellow,draw=none,opacity=0.8, path fading=north] (-3.8,3.2) rectangle     (3.84,2);%<------------
  \end{scope}
  \node[anchor=west] at (4.5,3.5) {hv};
  \draw[dash pattern=on 20pt off 10pt,line width=30pt,draw=white] (-4,2.5) -- (4,2.5);
  \draw[dash pattern=on 20pt off 10pt,line width=2pt] (-4,3) -- (4,3);
  \node[anchor=west] at (4.5,3) {Mask};
  \filldraw[fill=blue!20]
    (4,1.5)
    decorate { -- (4,2) }
    -- (-4,2)
    decorate { -- (-4,1.5) };
  \node[anchor=west] at (4.5,1.75) {Hydrogel};
  \filldraw[fill=orange] 
    (-4,0) -- (4,0)
    decorate { -- (4,1.5) }
    -- (-4,1.5)
    decorate { -- (-4,0) };
  \node[anchor=west] at (4.5,0.75) {Substrat};
\end{tikzpicture}

输出为

相关内容