8

I have made the following drawing using the original drawing on the tikzpgf manual's cover page (link). But now I want to have one of those wave like shapes to be expanded in the corner of my page with fading colours.

I mean, I want a wave type drawing, fill a quarter of a circle and the colour of it fade when the distance to the centre increases. Also, I want to decrease the segments sizes when it comes so near to the edge of the circle.

enter image description here

\documentclass[a4paper,12pt,twosided,openright]{book}
\usepackage{tikz,pgfplots,pgfplotstable}
\usetikzlibrary{trees,snakes}


\begin{document}
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\tikzstyle{edge from parent}=[snake=expanding waves,segment length=1mm,segment angle=10,draw]
\begin{tikzpicture}[shape=circle,very thick,level distance=13mm,cap=round]
\node {} child [color=\A] foreach \A in {red,green,blue}
    { node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
        { node {} child [color=\A!50!\B!50!\C] foreach \C in {black,gray,white}
            { node {} }
        }
    };
\end{tikzpicture}

\end{document}
15

Here is a possible solution:

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.north west) circle (3mm);
    \def\max{20}
    \foreach \i in {4,...,\max} {
      \draw[red,line width=.5mm,draw opacity={(\max-\i)/(\max-4)}]
      (current page.north west) ++(\i mm,0)
      arc[start angle=0,end angle=-90,radius=\i mm];
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\end{document}

enter image description here

Another version with variable thickness:

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.north west) circle (3mm);
    \def\max{200}
    \foreach \i in {4,...,\max} {
      \pgfmathsetmacro\prop{(\max-\i)/(\max-4)}
      \draw[red,line width={.7mm*\prop},draw opacity=\prop]
      (current page.north west) ++(\i mm,0)
      arc[start angle=0,end angle=-90,radius=\i mm];
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\end{document}

enter image description here

  • Can you do something with their thickness? Like they fade in colour, their thickness decrease... – Enthusiastic Engineer Oct 30 '14 at 15:02
  • @EnthusiasticStudent: You can play around with the line width. Start with something like line width=3.0mm/\i and adjust this function as desired. – Peter Grill Oct 30 '14 at 15:16
  • 2
    nice moiré effect :) – yo' Oct 30 '14 at 22:36
7

Credits should go to Paul Gabroit because I didn't understand the question first. Thanks to him for the code too. Here is a variation of his answer.

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave[1][north west]{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.#1) circle (3mm);
    \def\max{20}
    \foreach \i in {4,...,\max} {
      \draw[red!\i!green,line width=12/\i mm,draw opacity={(\max-\i)/(\max-4)}]
      (current page.#1) circle (\i mm);
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\wave[north east]
\wave[south west]
\wave[south east]
\end{document}

enter image description here

  • why cannot I put \max{200}? – Enthusiastic Engineer Oct 30 '14 at 16:45
  • @EnthusiasticStudent Use red (or any single color) instead of red!\i!green if you want \max{200}. It will take color out of bounds. – user11232 Oct 30 '14 at 23:09
5

I took a different approach and added fading to the expanding wave decoration:

fading wave

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}

\pgfdeclaredecoration{fading waves}{initial}
{
  \state{initial}[width=+\pgfdecorationsegmentlength,next state=wave]
  {\gdef\opacity{1}}

  \state{wave}[switch if less than=+\pgfdecorationsegmentlength to last,
               width=+\pgfdecorationsegmentlength]
  {
    \pgfpathmoveto{
      \pgfpointadd
      {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
      {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
    \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
    \pgfsetstrokeopacity{\opacity}%
    \pgfusepath{stroke}%
    \pgfmathmultiply{0.7}{\opacity}% adjustable fade rate
    \global\edef\opacity{\pgfmathresult}%
  }
  \state{last}[width=+0pt,next state=final]
  {
    \pgfpathmoveto{
      \pgfpointadd
      {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
      {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
    \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
    \pgfsetstrokeopacity{\opacity}%
    \pgfusepath{stroke}%
  }
  \state{final}
  {
    \pgfpathmoveto{\pgfpointdecoratedpathlast}
  }
}

\begin{document}

\begin{tikzpicture}[shape=circle,very thick,level distance=13mm,cap=round]
\draw[decorate,decoration={fading waves,angle=45}] (0,0) -- (1,-1);
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.