8

I have the following code:

\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}

Which results in this image:

enter image description here

Now I want to add a shiny effect to the hv, like a blurred outline. How is this achievable?

1 Answer 1

8

One idea would be to use path fading. For instance, I used path fading = south in hydrogel. The code is

\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}

The output is

:

Or if you like the HV to be shiny, try this

\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}

The output is

1
  • @Reza: You are so welcome! Glad to help! Enjoy!
    – Thanos
    Commented Feb 2, 2013 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .