Happy Christmas!

Happy Christmas to everyone!

For all, who don’t celebrate christmas, have a great holiday season too!

The picture of this greeting card was made in TikZ by cfr, our catcode specialist. (You noticed the cat.)

christmas-tree

What would christmas be without code!

\documentclass[tikz, border=5pt, rgb, x11names, svgnames, dvipsnames]{standalone}
\usepackage{forest}
\usetikzlibrary{shapes.geometric,backgrounds,shadows,fit,fadings,calc}
\pgfdeclarelayer{foreground}
\pgfdeclarelayer{boncyff}
\pgfdeclarelayer{canghennau}
\pgfdeclarelayer{goleuni}
\pgfsetlayers{background,canghennau,boncyff,goleuni,main,foreground}
\makeatletter
% adapted (simplified version) from tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybackgrounds.code.tex
\tikzset{%
  on foreground layer/.style={%
    execute at begin scope={%
      \pgfonlayer{foreground}%
      \let\tikz@options=\pgfutil@empty%
      \tikzset{every on foreground layer/.try,#1}%
      \tikz@options%
    },
    execute at end scope={\endpgfonlayer}
  },
  on canghennau layer/.style={
    execute at begin scope={%
      \pgfonlayer{canghennau}%
      \let\tikz@options=\pgfutil@empty%
      \tikzset{every on canghennau layer/.try,#1}%
      \tikz@options%
    },
    execute at end scope={\endpgfonlayer}
  },
  on boncyff layer/.style={
    execute at begin scope={%
      \pgfonlayer{boncyff}%
      \let\tikz@options=\pgfutil@empty%
      \tikzset{every on boncyff layer/.try,#1}%
      \tikz@options%
    },
    execute at end scope={\endpgfonlayer}
  },
  on goleuni layer/.style={
    execute at begin scope={%
      \pgfonlayer{goleuni}%
      \let\tikz@options=\pgfutil@empty%
      \tikzset{every on goleuni layer/.try,#1}%
      \tikz@options%
    },
    execute at end scope={\endpgfonlayer}
  },
  aa/.store in=\cfr@aa,
  aa=0,
  pics/anrheg/.style n args={2}{
    code={
      \node (-bocs) [anchor=north, rounded corners=2pt, outer sep=0pt, minimum width=5mm, minimum height=5mm, fill=#1, rotate=\cfr@aa] {};
      \path [fill=#2, draw=#2, rotate=\cfr@aa]
      ([xshift=-.5mm]-bocs.south)
      [out=80, in=-105] to ([xshift=.5mm]-bocs.north)
      [out=175, in=5] to ([xshift=-.5mm]-bocs.north)
      [out=-85, in=100] to ([xshift=.5mm]-bocs.south)
      [out=-175, in=-5] to cycle;
      \path [fill=#2, draw=#2, rotate=\cfr@aa]
      ([yshift=.5mm]-bocs.west)
      [out=-10, in=-175] to ([yshift=-.5mm]-bocs.east)
      [out=85, in=-85] to ([yshift=.5mm]-bocs.east)
      [out=-175, in=-10] to ([yshift=-.5mm]-bocs.west)
      [out=95, in=-95] to cycle;
    },
  },
}
\makeatother
\tikzfading[
  name=disglair,
  inner color=transparent!0,
  outer color=transparent!100]
\colorlet{lliw1}{Crimson}
\colorlet{lliw2}{DeepPink}
\colorlet{lliw3}{Violet}
\colorlet{lliw4}{Purple3}
\colorlet{lliw5}{Cyan}
\colorlet{lliw6}{Green1}
\colorlet{lliw7}{Gold}
\colorlet{lliw8}{Aquamarine1}
\colorlet{lliw0}{OrangeRed1}
\colorlet{lliwanrheg1a}{WildStrawberry}
\colorlet{lliwanrheg1b}{Ivory}
\colorlet{lliwanrheg2a}{Red1}
\colorlet{lliwanrheg2b}{Yellow1}
\colorlet{lliwanrheg3a}{Turquoise2}
\colorlet{lliwanrheg3b}{WildStrawberry}
\colorlet{lliwanrheg4a}{Yellow1}
\colorlet{lliwanrheg4b}{DodgerBlue3}
\colorlet{lliwanrheg5a}{Ivory}
\colorlet{lliwanrheg5b}{Turquoise2}
\colorlet{lliwanrheg0a}{DodgerBlue3}
\colorlet{lliwanrheg0b}{Red1}
\begin{document}
\forestset{
  declare count register=nodes y goeden,
  nodes y goeden'=0,
  declare count register=tier count,
  tier count'=1,
  % canghennau
  cangen chwith/.style={
    edge path={
      \noexpand\scoped[on canghennau layer]{
        \noexpand\path [draw=ForestGreen, thick, \forestoption{edge}]
          (!u.parent anchor) +(0,20pt) [out=-90, in=150] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,15pt) [out=-90, in=150] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,10pt) [out=-90, in=150] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,5pt) [out=-90, in=150] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) [out=-90, in=150] to (.child anchor)\forestoption{edge label};
      }
    },
  },
  cangen dde/.style={
    edge path={
      \noexpand\scoped[on canghennau layer]{
        \noexpand\path [draw=ForestGreen, thick, \forestoption{edge}]
          (!u.parent anchor) +(0,20pt) [out=-90, in=30] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,15pt) [out=-90, in=30] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,10pt) [out=-90, in=30] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) +(0,5pt) [out=-90, in=30] to (.child anchor)\forestoption{edge label}
          (!u.parent anchor) [out=-90, in=30] to (.child anchor)\forestoption{edge label};
      }
    },
  },
  plant/.style={
    before typesetting nodes={
      repeat=#1{
        prepend={[, bud, cangen chwith]},
        append={[, bud, cangen dde]},
      },
    },
  },
  boncyff/.style={
    edge path={
      \noexpand\scoped[on boncyff layer]{
        \noexpand\path [line cap=round, line width=2.5pt, draw=Chocolate4, \forestoption{edge}] (!u.parent anchor) -- (.child anchor)\forestoption{edge label};
      }
    },
  },
  seren/.style={
    star, minimum size=25pt, star points=7, star point ratio=3, parent anchor=south, outer sep=2pt, inner color=white, outer color=Gold1, draw=Goldenrod1, inner color=white, outer color=Silver, draw=Snow3, tikz={\scoped[on goleuni layer]\node (sglein) [minimum width=50pt, circle, inner color=white, outer color=Silver, path fading=disglair] {};}
  },
  enw/.style={
    nodes y goeden'+=1,
    name/.process={Rw}{nodes y goeden}{n##1},
  },
  anrheg/.style={
    no edge, enw, anchor=north
  },
  bud/.style={
    inner sep=0pt,
    outer sep=0pt,
    parent anchor=center,
    child anchor=center,
    enw,
  },
  gwag/.style={
    inner sep=0pt,
    outer sep=0pt,
    parent anchor=center,
    child anchor=center,
    no edge,
  },
}
\begin{forest}
  for tree={
    if level=0{}{
      bud,
    },
    boncyff,
    if n=1{
      tier count'+=1,
    }{},
    s sep+=7.5,
    before computing xy={
      l/.process={Rw+n+d}{tier count}{4*#1 pt}
    },
    before typesetting nodes={
      if n children=0{
        append={
          [, bud, boncyff
            [, bud, l'=2pt, boncyff
              [, anrheg, alias=troed, before computing xy={l'=0pt}
              ]
            ]
          ]
        },
        delay={
          for children={
            if={

OOw+n={n}{!u.n children}{(#1+1)/2} }{}{ append={ [, gwag, l'=2pt [, anrheg, before computing xy={l'=7.5pt} ] ] }, }, }, }, }{}, }, }, [, seren, plant=1 [, plant=2 [, plant=3 [, plant=4 [, plant=5 [, plant=6 ] ] ] ] ] ] \foreach \i in {1,...,50} { \ifnum\i=29\relax\else\ifnum\i=28\relax\else \pgfmathsetmacro{\result}{int(mod(\i,9))} \node [circle, ball color=lliw\result] at (n\i) {}; \scoped[on goleuni layer] \node [circle, minimum width=20pt, inner color=lliw\result!50!white, outer color=lliw\result!50!Silver, path fading=disglair] at (n\i) {}; \fi\fi } \foreach \i in {51,...,62} { \tikzset{aa=0} \pgfmathsetmacro{\result}{int(mod(\i,6))} \pgfmathsetmacro{\casgliad}{int(mod(4+\i,6))} \pgfmathsetmacro{\nesaf}{int(1+\i)} \ifnum\i>56 \pic at (n\i) {anrheg={lliwanrheg\result a}{lliwanrheg\result b}}; \else \pic at (n\i) {anrheg={lliwanrheg\result b}{lliwanrheg\result a}}; \fi \tikzset{aa=45} \ifnum\i<56 \pic at ([yshift=3.85mm,xshift=.25pt]$(n\i)!1/4!(n\nesaf)$) {anrheg={lliwanrheg\casgliad a}{lliwanrheg\casgliad b}}; \fi \tikzset{aa=-45} \ifnum\i>56 \ifnum\i<62 \pic at ([yshift=3.85mm,xshift=-.25pt]$(n\i)!3/4!(n\nesaf)$) {anrheg={lliwanrheg\casgliad b}{lliwanrheg\casgliad a}}; \fi \fi } \path (n29) ++(0,-1.5mm) coordinate (c0) (c0) arc (-90:0:5mm and 2.5mm) coordinate (c1) (c0) arc (-90:-180:5mm and 2.5mm) coordinate (c2) (c0) +(2.5mm,-4.5mm) coordinate (c3) (c0) +(-2.5mm,-4.5mm) coordinate (c4) (c1) +(0,-2mm) coordinate (c5) (c2) +(0,-2mm) coordinate (c6) ; \path [fill=Sienna1] (c2) arc (-180:0:5mm and 2.5mm) -- (c5) -- (c3) arc (0:-180:2.5mm and 1.25mm) -- (c6) -- cycle; \begin{scope} \clip (c2) arc (-180:0:5mm and 2.5mm) -- (c5) -- (c3) arc (0:-180:2.5mm and 1.25mm) coordinate [midway] (c7) -- (c6) -- cycle; \path [draw=Sienna3] (c6) arc (-180:0:5mm and 2.5mm); \path [draw=Sienna3] (c2) arc (-180:0:5mm and 2.5mm); \end{scope} \begin{scope}[on canghennau layer] \path [fill=Sienna1, draw=Sienna3] (c2) arc (-180:180:5mm and 2.5mm); \path [fill=Brown!50!black] (n29 |- c2) circle (4mm and 2mm); \end{scope} \begin{scope}[on background layer] \node [fill=MidnightBlue, inner sep=15pt, fit=(sglein) (troed) (n21) (n35) (c7) (n51) (n62) (cath)] {}; \end{scope} % \foreach \i in {1,...,62} \node (anrheg \i) [red] at (n\i) {\i}; \end{forest} \end{document}

One thought

  1. Why I couldn’t get the card? Here’s the mistake:

    (c:/texlive/2016/texmf-dist/tex/generic/pgf/libraries/pgflibraryfadings.code.te
    x))) (./MaryCherismas.aux) ABD: EveryShipout initializing macros
    Runaway argument?
    { if level=0{}{ bud, }, boncyff, if n=1{ tier count’+=1, }{}, s sep+=\ETC.
    ! Paragraph ended before \bracket@Parse@appendGroup was complete.

    \par
    l.272 \end{forest}

    ?

Leave a Reply