Example: Fireworks

Published 2011-12-31 | Author: percusse

Posted for celebrating the New Year on TeX.SX.

Displayed with TeXworks PDF previewer. Some PDF viewers don’t display correctly, noticed with Adobe Reader on Linux and Evince on Linux.

Download as: [PDF] [TEX]


Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Fireworks
% Author: percusse
\begin{tikzpicture}[projectile/.style={decorate,decoration={random steps,
  segment length=3pt,amplitude=0.5pt}}]
  \fill[black] (-4,-4) rectangle (6,5);

  \begin{scope}[xshift=0cm,yshift=-0.4cm,transparency group]
    \foreach \x in {0,6,..., 360}{\draw[blue!80!white,projectile,line width=1.1pt]
      (0,0) to [in=90] (10*rand+\x:rand*1mm+2cm);};

    \foreach \x in {0,8,..., 360}{\draw [yellow!5,thick,projectile] (0.7,0)
      to  (3*rand+\x :1mm*rand+2.2cm)  node[circle,inner sep=1mm,
      shade,shading=somenodeshade,opacity=0.1] {};}
    \fill[white] (-3,-3) rectangle (3,3);

    \foreach \x in {0,10,..., 360}{\def\r1{rand}\draw [yellow]
      ($(0,0)!abs{\r1}!(\x :5mm)$) to [in=90] ($(0,0)!abs{\r1}+0.2!(\x :8mm)$);}
    \fill[yellow,opacity=0.6] (-3,-3) rectangle (3,3);

    \foreach \x in {0,12,..., 360}{\def\r2{rand}\draw [red,line width=0.5pt]
      ($(0,0)!abs{\r2}!(\x :3mm)$) -- ($(0,0)!abs{\r2}+0.1!(\x :7mm)$);}
    \fill[red,opacity=0.6] (-3,-3) rectangle (3,3);


  • #1 rajendra, January 1, 2012 at 3:26 p.m.

    something is missing, I could not reuse the code. there is an error, something like :

    ! Missing $ inserted. $ l.41 ...[in=90] ($(0,0)!abs{\r1}+0.2!(\x :8mm)$);}

  • #2 alkaios, February 1, 2012 at 7:30 p.m.

    the same problem.something wrong with the code...

  • #3 percusse, February 12, 2012 at 10:48 p.m.

    For those who encounter errors, can you please include more information about the error? I have updated the code a few times on TeX.SX (see the link above in the description). Moreover, I can compile the given code under TeXnicCenter 2 Alpha 3 (and 4) - MikTeX 2.9.

    There is a PDF Viewer issue that gives a different output at each PDF Reader (I have received comments about the different effects of LCD displays too!) The code on TeX.SX seems working for Sumatra PDF but looks bad under Acrobat X.

Adding comments is currently not enabled.