17

In the spirit of How can we draw a Christmas tree with decorations, using TikZ?, how can we realize Christmas animations with TikZ?

For example:

enter image description here

or also:

enter image description here

1 Answer 1

22

Here is my start:

\documentclass[x11names]{beamer}
\usepackage{lmodern}
\usepackage{tikzorbital}
\usetikzlibrary{backgrounds,
  lindenmayersystems,
  decorations.pathmorphing,
  decorations.markings,
  shapes.geometric,
  calc,
  shapes.symbols,
  }
\pgfdeclarelayer{endroom}
\pgfdeclarelayer{window}
\pgfdeclarelayer{back window}
\pgfsetlayers{endroom,back window,window,background,main} 

\setbeamertemplate{navigation symbols}{}

\setlength{\textwidth}{\paperwidth}
\setlength{\textheight}{\paperheight}

% original code by percusse:
% http://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines#49961
\makeatletter
\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=3mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
        }
    }
    \state{final}{}
}

\tikzset{pencil decoration/.style={decorate, decoration=penciline}}

\tikzset{fine random decoration/.style=decorate,decoration={random steps,segment length=0.8pt,amplitude=0.125pt}}

\pgfdeclareradialshading[tikz@ball]{bauble}{\pgfpoint{-0.275cm}{0.4cm}}{%
  rgb(0cm)=(1,1,1);
  color(0.4cm)=(tikz@ball!70!white); 
  color(0.6cm)=(tikz@ball); 
  color(0.8cm)=(tikz@ball!60!black); 
  rgb(1cm)=(1,1,1)
}
\tikzoption{bauble color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble}\tikz@addmode{\tikz@mode@shadetrue}}

\pgfdeclareradialshading[tikz@ball]{bauble off}{\pgfpoint{-0.275cm}{0.4cm}}{%
  rgb(0cm)=(1,1,1);
  color(0.185cm)=(tikz@ball!35!black); 
  color(0.8cm)=(tikz@ball!80!black); 
  rgb(1cm)=(1,1,1)
}
\tikzoption{bauble off color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble off}\tikz@addmode{\tikz@mode@shadetrue}}

\makeatother

% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
  background shade/.style={#1},
  shade on/.style={alt=#1{}{background shade}},
}


\tikzset{snow/.style={
    starburst, random starburst=#1,
    inner sep=2.5pt,scale=0.15,
    background shade={inner color=Snow3, outer color= Snow2},
  }
}

% original code by Andrew Stacey:
% http://tex.stackexchange.com/questions/39149/how-can-we-draw-a-christmas-tree-with-decorations-using-tikz#39209
\tikzset{
  tinsel/.style={
    #1,
    rounded corners=10mm,
    ultra thin,
    decorate,
    decoration={
      snake,
      amplitude=.1mm,
      segment length=10,
    }
  },
  baubles/.style={
    decorate,
    decoration={
      markings,
      mark=between positions .3 and 1 step 2cm
      with
      {
        \pgfmathsetmacro{\brad}{1.5 + .5 * rand}
        \tikzset{background shade/.default={shading=bauble off,bauble off color=#1}}
        \path[background shade={shading=bauble,bauble color=#1},shade on=<{2,4}>](0,0) circle[radius=\brad mm];
      }
    }
  },
  lights/.style={
    decorate,
    decoration={
      markings,
      mark=between positions 0 and 1 step 1cm
      with
      {
       \pgfmathsetseed{12345}
        \pgfmathparse{rand > 0 ? "dart" : "kite"}
        \let\lshape\pgfmathresult
         \pgfmathsetmacro{\tint}{100*rnd}
         \tikzset{background shade/.default={shading=bauble off,bauble off color=red!\tint!orange}}
        \node[rotate=90,\lshape,inner sep=1pt,
          background shade={shading=bauble,bauble color=red!\tint!yellow},
          shade on=<{1,3,5}>] {};
      }
    }
  }
}


\begin{document}
\begin{frame}
\begin{tikzpicture}
\useasboundingbox(0.25,0.25) rectangle (12,9.25);

\begin{pgfonlayer}{endroom}
\draw[very thin] (-0.5,0)--(2,1.25)--(9,1.25)--(11.75,0);
\draw[very thin] (-0.5,9.25)--(2,8.25)--(9,8.25)--(11.75,9.25);
\draw[very thin] (2,1.25)--(2,8.25);
\draw[very thin] (9,1.25)--(9,8.25);
\end{pgfonlayer}

% tree base coordinate
\coordinate (star) at (12,8.75);

% window
\begin{scope}
\pgfmathsetseed{123456}

\begin{pgfonlayer}{back window}
% outer
\draw[pencil decoration,fill=LightSalmon3!80] (2.75,5)node[inner sep=0pt](outer below left){}
   --(2.75,7)node[inner sep=0pt](outer above left){}
   --(5,7)node[inner sep=0pt](outer above right){}
   -- (5,5)node[inner sep=0pt](outer below right){}
   --cycle;

% inner
\draw[pencil decoration,top color=Blue3, bottom color=Blue3!30, shading angle=35] (2.95,5.2)node[inner sep=0pt](inner below left){}
   --(2.95,6.8)node[inner sep=0pt](inner above left){}
   --(4.8,6.8)node[inner sep=0pt](inner above right){}
   --(4.8,5.2)node[inner sep=0pt](inner below right){}
   --cycle;
\end{pgfonlayer}

\begin{pgfonlayer}{window}
\draw[pencil decoration,fill=LightSalmon3!80]
 ($(inner above left)!0.45!(inner above right)+(0,0.05)$)node[inner sep=0pt](internal above left){}
 --($(inner below left)!0.45!(inner below right)-(0,0.02)$)node[inner sep=0pt](internal below left){}
 --($(inner below left)!0.55!(inner below right)-(0,0.05)$)node[inner sep=0pt](internal below right){}
 --($(inner above left)!0.55!(inner above right)+(0,0.03)$)node[inner sep=0pt](internal above right){}
 --cycle;
\node[inner sep=0pt](opening) at ($(internal below left)!0.5!(internal above left)+(0.1,0)$){};
\orbital[pcolor=Goldenrod2, ncolor=Goldenrod2,scale=0.25,pos = {(opening)}]{pz}
\draw[radius=0.75bp, fill=Goldenrod2] (opening) circle ;
\end{pgfonlayer}

% SNOW

\coordinate (inner middle left) at ($(inner above left)!0.5!(inner below left)$);
\coordinate (inner middle right) at ($(inner above right)!0.5!(inner below right)$);

\coordinate (inner semi-middle right) at ($(inner above right)!0.3!(inner below right)$);
\coordinate (inner semi-middle left) at ($(inner above left)!0.3!(inner below left)$);

\coordinate (middle above left) at ($(inner above left)!0.5!(internal above left)$);
\coordinate (middle above right) at ($(inner above right)!0.5!(internal above right)$);

\coordinate (middle center left) at ($(inner middle left)!0.5!(opening)$);
\coordinate (middle center right) at ($(inner middle right)!0.5!(opening)$);

\coordinate (middle below left) at ($(inner below left)!0.5!(internal below left)$);
\coordinate (middle below right) at ($(inner below right)!0.5!(internal below right)$);

\foreach \xstep/\ystep/\sequence in {0.1/0.12/{1,2,4},0.2/0.2/{2,4,5},0.35/0.475/{1,3,5},0.575/0.7/{2,3,4}}{,
\tikzset{
    background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(inner above right)!\xstep!(internal above right)!\ystep!(opening)+(-0.075*rnd,-0.1*rnd)$) {};

\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(inner above right)!\xstep!(internal above right)!\ystep!(opening)+(0.3*rnd,-0.3*rnd)$) {};

\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(internal above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(-0.05*rnd,-0.2*rnd)$) {};

\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(internal above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(0.4*rnd,-0.375*rnd)$) {}; 

}

\foreach \xstep/\ystep/\sequence in {0.05/0.075/{2,3,5},0.2/0.215/{1,2,3,4},0.275/0.325/{1,4},0.45/0.55/{2,3,5}}{
\tikzset{
    background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult

\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(middle above right)!\xstep!(internal above right)!\ystep!(opening)+(-0.1*rnd,-0.025*rnd)$) {};

\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(middle above left)!\xstep!(inner above left)!\ystep!(inner middle left)+(-0.1*rnd,0.05*rnd)$) {};

 \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(-0.35*rnd,-0.05*rnd)$) {};

}

\foreach \xstep/\ystep/\sequence in {0.1/0.12/{1,2,5},0.2/0.2/{2,3,5},0.35/0.475/{1,3,4},0.575/0.7/{2,4}}{,
\tikzset{
    background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult
\node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(inner semi-middle right)!\xstep!(opening)!\ystep!(middle below right)+(-0.075*rnd,0.1*rnd)$) {};

 \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(inner semi-middle right)!\xstep!(opening)!\ystep!(middle below right)+(0.2*rnd,-0.2*rnd)$) {};

    \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(middle center right)!\xstep!(opening)!\ystep!(internal below right)+(0.1*rnd,-0.1*rnd)$) {};

   \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(0.125*rnd,-0.25*rnd)$) {};  

} 

\foreach \xstep/\ystep/\sequence in {0.2/0.15/{1,3,5},0.225/0.35/{2,4},0.35/0.475/{1,2,3,5},0.6/0.7/{1,2,4}}{,
\tikzset{
    background shade/.default={inner color=Snow1, outer color= Snow1!50}
}
\pgfmathrandom{200}
\pgfmathtruncatemacro\rndstartburst\pgfmathresult

  \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(opening)!\xstep!(middle center left)!\ystep!(inner below left)+(0.1*rnd,-0.2*rnd)$) {};  

  \node[snow=\rndstartburst,shade on=<{\sequence}>] 
 at ($(middle center left)!\xstep!(inner middle left)!\ystep!(inner below left)+(0.1*rnd,0.35*rnd)$) {};  
}

\node[snow=10,shade on=<{2,3,4}>] 
 at ($(inner middle left)!0.8!(opening)!0.25!(internal above left)$) {};
 \node[snow=10,shade on=<{1,4}>] 
 at ($(inner middle left)!0.4!(opening)!0.8!(internal below left)$) {};
\end{scope}
\end{tikzpicture}

%% Christmas tree
\scalebox{0.65}{
\begin{tikzpicture}[overlay,remember picture]
\path (star) +(-50:7) coordinate (rhs) +(-130:7) coordinate (lhs);
\draw[brown!50!black,line width=5mm,line cap=round] (star) ++(-90:6.8) -- ++(0,-1) coordinate (base);
\node[scale=-1,trapezium,fill=black,minimum size=1cm] at (base) {};
\foreach \height/\colour in {%
  .2/blue,
  .4/yellow,
  .6/red,
  .8/orange,
  1/pink%
} {
  \draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\path (star);
\pgfgetlastxy{\starx}{\stary}
\begin{scope}[xshift=\starx,yshift=\stary,yshift=-7cm]
\draw[color=green!50!black, l-system={rule set={S -> [+++G][---G]TS,  G -> +H[-G]L, H -> -G[+H]L, T -> TL, L -> [-FFF][+FFF]F}, step=4pt, angle=18, axiom=+++++SLFFF, order=11}] lindenmayer system -- cycle;
\end{scope}
\foreach \height/\colour in {%
  .1/pink,
  .3/red,
  .5/yellow,
  .7/blue,
  .9/orange%
} {
  \draw[tinsel=\colour] ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}
\foreach \height in {.15,.35,...,1} {
  \draw[lights]  ($(star)!\height!(lhs)$) to[bend right] ($(star)!\height!(rhs)$);
}

\foreach \angle/\colour in {
  -50/red,
  -70/yellow,
  -90/blue,
  -110/Green2,
  -130/MediumOrchid1%
} {
  \draw[baubles=\colour] (star) -- ++(\angle:7);
}

\node[star,star point ratio=2.5,fill=yellow,minimum size=1cm] at (star) {};
\end{tikzpicture}
}
\end{frame}
\end{document}

Merry Christmas

enter image description here


A Christmas wreath:

enter image description here

\documentclass[x11names]{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{lindenmayersystems,positioning,decorations.text}

\setbeamertemplate{navigation symbols}{}

\makeatletter
\pgfdeclareradialshading[tikz@ball]{bauble}{\pgfpoint{-0.275cm}{0.4cm}}{%
  rgb(0cm)=(1,1,1);
  color(0.4cm)=(tikz@ball!70!white); 
  color(0.6cm)=(tikz@ball); 
  color(0.8cm)=(tikz@ball!60!black); 
  rgb(1cm)=(1,1,1)
}
\tikzoption{bauble color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble}\tikz@addmode{\tikz@mode@shadetrue}}

\pgfdeclareradialshading[tikz@ball]{bauble off}{\pgfpoint{-0.275cm}{0.4cm}}{%
  rgb(0cm)=(1,1,1);
  color(0.185cm)=(tikz@ball!35!black); 
  color(0.8cm)=(tikz@ball!80!black); 
  rgb(1cm)=(1,1,1)
}
\tikzoption{bauble off color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{bauble off}\tikz@addmode{\tikz@mode@shadetrue}}

\makeatother

% original code by Daniel:
% http://tex.stackexchange.com/questions/55806/tikzpicture-in-beamer#55849
\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

% original code in
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes#84608
\tikzset{
  background shade/.style={#1},
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background text/.style={text=#1},
  background text/.default={red},
  text on/.style={alt=#1{}{background text}},
}

\tikzset{background shade/.default={
        shading=bauble off,
        bauble off color=red
    },
    bauble size/.style={
        circle,
        inner sep=3pt,
    }
}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw [green!60!black,rotate=90] l-system
[l-system={rule set={F -> F[+FF]F[-FF] ->F[+FF]F[-FF]}, axiom=F, order=4, angle=15,step=4pt}];

\node[background text={green!50!black},text on=<{2,4,5,7,9,10}>,scale=1.1](m) at ([xshift=1cm,yshift=2cm]0,0){Merry};
\node[text=Yellow2,scale=1.17] at ([xshift=1cm,yshift=2cm]0,0){Merry};
\node[background text={green!50!black},text on=<{2,4,5,7,9,10}>,scale=1.1] at ([xshift=1cm,yshift=2cm]0,-0.2){Christmas};
\node[text=Yellow2,scale=1.17]at([xshift=1cm,yshift=2cm]0,-0.2){Christmas};

\foreach \pos/\initlight in {{(-0.35,1)}/{1,2,3},{(1,-1.5)}/{2,3},{(2.35,1)}/{1,3}}{
\node[bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,5,7,10}>](node1)
 at \pos {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,6,7,9}>](node2) 
 at (node1.south west) {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,6,8,10}>](node3) 
 at (node1.south east) {};
}

\foreach \pos/\initlight in {{(-0.6,-0.5)}/{1,2},{(2.6,-0.5)}/{1,2}}{
\node[bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,6,7,9}>](node1)
 at \pos {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,5,8,10}>](node2) 
 at (node1.south west) {};
\node[below=-0.05cm,bauble size,background shade={shading=bauble,bauble color=red},shade on=<{\initlight,4,5,7,8,9}>](node3) 
 at (node1.south east) {};
}
\end{tikzpicture}
\end{frame}
\end{document}
2

You must log in to answer this question.

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