2

Consider the following code:

\documentclass{article}

\usepackage{expl3}
\usepackage{tikz}

\usetikzlibrary{
  hobby,
  shapes.geometric,
  decorations,
  decorations.shapes,
  shapes.geometric,
  patterns
}

% http://www.guitex.org/home/it/forum/5-tex-e-latex/83195-la-libreria-hobby-tikz-non-funziona-piu#83203
\ExplSyntaxOn
  \cs_if_exist:NF \prg_stepwise_function:nnnN { \cs_gset_eq:NN \prg_stepwise_function:nnnN \int_step_function:nnnN }
  \cs_if_exist:NF \prg_stepwise_inline:nnnn { \cs_gset_eq:NN \prg_stepwise_inline:nnnn \int_step_inline:nnnn }
\ExplSyntaxOff

\makeatletter
\pgfdeclareradialshading[tikz@ball]{easter bg}{\pgfpoint{5bp}{25bp}}{%
  color(0cm)=(tikz@ball!20);
  color(0.15cm)=(tikz@ball!30);
  color(0.4cm)=(tikz@ball!60);
  color(0.9cm)=(tikz@ball)
}
\tikzoption{easter bg color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter bg}\tikz@addmode{\tikz@mode@shadetrue}}

\pgfkeys{/tikz/easter star/.code args={#1 and #2}{
  \pgfdeclareradialshading[tikz@ball]{easter star}{\pgfpoint{#1}{#2}}{%
  color(0cm)=(tikz@ball!20);
  color(0.3cm)=(tikz@ball!40);
  color(0.65cm)=(tikz@ball!60);
  color(1cm)=(tikz@ball)
  }
 }
 \tikzoption{easter star color}{\pgfutil@colorlet{tikz@ball}{#1}\def\tikz@shading{easter star}\tikz@addmode{\tikz@mode@shadetrue}}
}
\makeatother

% original code by Paul Gaborit:
% tex.stackexchange.com/questions/72784/arrow-with-two-colors-with-tikz/#72793
\tikzset{
  double path/.style args = {#1 colored by #2 and #3}{
    -, line join = round, line cap = rect,
    shorten >= 0.1cm,
    shorten <= 0.1cm,
    line width = #1,#2, % first path
    postaction = {
      draw,-,
      #3,
      line width = (#1)/1.5,
      shorten <= (#1)/3,
      shorten >= (#1)/3
    } % second path
  }%
}

\tikzset{easter decoration 1/.style = {
    decorate,
    decoration = {
      shape backgrounds,
      shape = star,
      shape size = 7pt,
      shape sep = {0.5cm, between center}
    },
    inner color = yellow,
    outer color = yellow!50!orange,
    draw = red!20!orange
  }%
}

\pgfdeclarepatternformonly{fivepointed stars easter 2}{\pgfpointorigin}{\pgfpoint{10mm}{10mm}}{\pgfqpoint{10mm}{8mm}}%
{
  \pgftransformshift{\pgfqpoint{1mm}{1mm}}
  \pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{162}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{306}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{90}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{234}{1mm}}
  \pgfpathclose%
  \pgfusepath{fill}
}

\tikzset{easter decoration 3/.style={
    draw=green!17!yellow,
    line width=2pt,
    star
  }
}

\pgfdeclarepatternformonly{fivepointed stars easter 3}{\pgfpointorigin}{\pgfpoint{12mm}{12mm}}{\pgfqpoint{12mm}{11mm}}%
{
  \pgftransformshift{\pgfqpoint{1mm}{1mm}}
  \pgfpathmoveto{\pgfqpointpolar{18}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{162}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{306}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{90}{1mm}}
  \pgfpathlineto{\pgfqpointpolar{234}{1mm}}
  \pgfpathclose%
  \pgfusepath{fill}
}


\begin{document}

\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~1};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) to[closed,curve through={ (0.775,0.35) .. (0.5,1) .. (0.225,0.35)}] (0.5,0.1);
  % Shading.
  \shade[easter bg color=orange,scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Colored paths.
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.775,0.35) .. (0.735,0.35)  .. (0.65,0.3) .. (0.45,0.4) .. (0.235,0.355) .. (0.225,0.35);
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.9,0.5) .. (0.775,0.55)  .. (0.55,0.5) .. (0.45,0.6) .. (0.235,0.55) .. (0.1,0.5);
  \draw[double path=5pt colored by orange!80!yellow and yellow,scale=-6] (0.9,0.7) .. (0.775,0.75)  .. (0.55,0.7) .. (0.45,0.8) .. (0.235,0.75) .. (0.1,0.7);
  % Stars.
  \draw[easter decoration 1,scale=-6] (0.775,0.25) .. (0.735,0.25)  .. (0.65,0.2) .. (0.45,0.3) .. (0.235,0.255) .. (0.225,0.25);
  \draw[easter decoration 1,scale=-6] (0.9,0.4) .. (0.775,0.45)  .. (0.55,0.4) .. (0.45,0.5) .. (0.235,0.45) .. (0.1,0.4);
  \draw[easter decoration 1,scale=-6] (0.9,0.6) .. (0.775,0.65)  .. (0.55,0.6) .. (0.45,0.7) .. (0.235,0.65) .. (0.1,0.6);
  \draw[easter decoration 1,scale=-6] (0.9,0.8) .. (0.775,0.85)  .. (0.55,0.8) .. (0.45,0.9) .. (0.235,0.85) .. (0.1,0.8);
  % Draw the border again.
  \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}
% Easter Egg 2.
\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~2};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Shading.
  \draw[easter bg color=blue!65!cyan,scale=-6,postaction={pattern=fivepointed stars easter 2,pattern color=blue}](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  \begin{scope}[transform canvas={shift={(-3.5,-3.5)}}]
   \node[star,scale=2.25,easter star=2bp and 10bp, easter star color=cyan!65!blue] at (0.35,0.75){};
   \node[star,scale=1.5,easter star=-2bp and 15bp, easter star color=cyan!85!blue,rotate=10] at (1.45,1.45){};
   \node[star,scale=1.5,easter star=5bp and 10bp, easter star color=cyan!75!blue,rotate=-10] at (-0.5,1.95){};
   \node[star,scale=1.65,easter star=5bp and 15bp, easter star color=cyan!45!blue,rotate=-5] at (-0.75,-0.85){};
   \node[star,scale=1.7,easter star=5bp and 15bp, easter star color=cyan!37!blue,rotate=-3] at (0,-1.65){};
   \node[star,scale=1.5,easter star=5bp and 10bp, easter star color=cyan!60!blue,rotate=2] at (0.85,-0.65){};
   \node[star,scale=1.75,easter star=-2bp and 2bp, easter star color=cyan!60!blue,rotate=14] at (2,0){};     
  \end{scope}
   % Draw the border again.
   \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}
% Easter Egg 3.
\begin{tikzpicture}[use Hobby shortcut]
  \node[above,xshift=-3.5cm,yshift=-1.5cm] at (0.5,1){Påskeæg~3};
  % Path clipping.
  \clip[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  % Shading.
  \draw[easter bg color=green!77!blue,scale=-6,postaction={pattern=fivepointed stars easter 3,pattern color=green!20!yellow}](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
  \begin{scope}[transform canvas={shift={(-3.5,-3.5)}}]
   \node[easter decoration 3,scale=2.25] at (0.55,0.65){};
   \node[easter decoration 3,scale=1.5,rotate=10] at (1.45,1.45){};
   \node[easter decoration 3,scale=1.5,rotate=-10] at (-0.5,1.95){};
   \node[easter decoration 3,scale=1.65,rotate=-5] at (-0.75,-0.70){};
   \node[easter decoration 3,scale=1.7,rotate=-3] at (0,-1.65){};
   \node[easter decoration 3,scale=1.5,rotate=2] at (0.85,-0.65){};
   \node[easter decoration 3,scale=1.75,rotate=14] at (2,0){};     
  \end{scope}
  % Draw the border again.
  \draw[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);
\end{tikzpicture}

\end{document}

Earlier, the code above has produced a picture of three easter eggs, but now I get the following error:

! Undefined control sequence.
<argument> \fp_if_undefined:NTF 
                                \l_hobby_out_angle_fp {\array_put:Nnx \l_hob...
l.113 ... .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1);

Can anyone help me modify the code to make it work again?

P.S. I don't use TikZ myself at all.

  • You are not loading hobby. However changing \clip[scale=-6](0.5,0.1) .. (0.775,0.35)[closed=true] .. (0.5,1) .. (0.225,0.35) .. (0.5,0.1); to \clip[scale=-6](0.5,0.1) to[closed,curve through={ (0.775,0.35) .. (0.5,1) .. (0.225,0.35)}] (0.5,0.1); may be helpful. – user11232 Aug 11 '14 at 2:03
  • @HarishKumar Thanks. However, the error persists. – Svend Tveskæg Aug 11 '14 at 3:00
  • Could you rerun the code with \usetikzlibrary{hobby} in the preamble and report the new error? – Loop Space Aug 11 '14 at 7:11
  • 1
    When I try your code with the hobby library loaded then I get an error about decorations, again probably missing some library. Even though you say you don't use TikZ, you know enough about LaTeX to know that when you cut-and-paste code, you need to get the preamble right! – Loop Space Aug 11 '14 at 7:20
  • @LoopSpace Sorry. I completely missed the code about the libraries. (I've updated my question.) – Svend Tveskæg Aug 11 '14 at 11:50
5

The hobby package uses LaTeX3 internally very extensively. So when LaTeX3 functions get updated, the hobby package sometimes needs fixing and updating itself. Once this has been done, it needs uploading to CTAN. It appears that although hobby has been updated in line with the latest modifications to LaTeX3, these updates have not yet been uploaded to CTAN and therefore are not in the version that comes with, say, TeXLive.

In the meantime, it is possible to download hobby directly from the TeX-SX Packages Repository on Launchpad (download hobby.dtx, generate the files with tex hobby.dtx).

So try again with the latest version of hobby from TeX-SX Launchpad and I think you'll find that it works just fine.

  • Which changes have caused issues? – Joseph Wright Aug 11 '14 at 15:58
  • When I run tex hobby.dtx on the newest hobby.dtx, I now get the error ! Missing $ inserted. <inserted text> $ <to be read again> _ l.11 var global_ path = '/~tex-sx/tex-sx/development/';. – Svend Tveskæg Aug 11 '14 at 16:24
  • @SvendTveskæg I just downloaded it from Launchpad to a new directory, ran tex hobby.dtx to generate the files (with no errors), took your code and it compiled with no problems. This is with TeXLive 2014, recently updated. – Loop Space Aug 11 '14 at 18:33
  • @JosephWright This particular problem was caused by the removal of \fp_if_undefined from the fp segment. It's used because there are some numbers that the user can configure or can be left unassigned. So there needs to be a test for "not assigned" and \fp_if_undefined seemed the best way to accomplish that. The workaround is to assign these fps to \c_inf_fp at initialisation and test for that instead of undefinedness. Similar things have happened before. – Loop Space Aug 11 '14 at 18:37
  • @LoopSpace With the newest TeX Live 2014 I still get the error ! Missing $ inserted. <inserted text> $ <to be read again> _ l.11 var global_ path = '/~tex-sx/tex-sx/development/';. Any chance I can make you generate the files and upload them somewhere? :) – Svend Tveskæg Aug 12 '14 at 10:35

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.