56

One of my last questions talked about certificates and I got great answers. Now my questions is, can one recreate a guilloche in TikZ like the one shown below:enter image description here

or may be a border like

enter image description here

3

3 Answers 3

46

Guilloché (Guilloche) is a decorative engraving technique in which a very precise intricate repetitive pattern or design is mechanically engraved into an underlying material with fine detail. Specifically, it involves a technique of engine turning, called guilloché in French after the French engineer “Guillot”, who invented a machine “that could scratch fine patterns and designs on metallic surfaces

The problem is to draw a curve with a fixed point inside a circle

A method : I used tkz-fct because it's my package and I know it but it's easy to create the same thing with only tikz. (here you need gnuplot)

enter image description here

\documentclass[11pt]{scrartcl}
\usepackage[dvipsnames]{xcolor}     
\usepackage{tkz-fct}


\begin{document} 

\def\spirographlike#1{%
\def\repeatno{#1}
 \foreach \i in {1,...,\repeatno}
   {%
    \begin{scope}[rotate=360/\repeatno*\i]
      \mycloedcurve
    \end{scope}}%
    } 

\def\mycloedcurve{\tkzFctPolar[color=MidnightBlue,thick,domain=0:2*pi,samples=400]{ 1+cos(3*t)+(sin(3*t))**2}}  

\noindent\begin{tikzpicture}
 \mycloedcurve 
\end{tikzpicture}    
\begin{tikzpicture}[scale=2]
 \tkzInit [xmin=-5,xmax=5,ymin=-5,ymax=5] 
  \spirographlike{40}    
\end{tikzpicture} 

\end{document}

update

enter image description here This is better but you need some time to compile

\documentclass[11pt]{scrartcl}
\usepackage[dvipsnames]{xcolor}     
\usepackage{tkz-fct}


\begin{document} 

\def\spirographlike#1{%
\def\repeatno{#1}
 \foreach \i in {1,...,\repeatno}
   {%
    \begin{scope}[rotate around={360/\repeatno*\i:(.5,0)}]
      \mycloedcurve
    \end{scope}}%
    } 

\def\mycloedcurve{\tkzFctPolar[color=MidnightBlue,thick,domain=0:2*pi,samples=400]{ 1+cos(3*t)+(sin(3*t))**2}}    

\begin{tikzpicture}
 \mycloedcurve 
\end{tikzpicture}    
\begin{tikzpicture}[scale=2]
 \tkzInit [xmin=-5,xmax=5,ymin=-5,ymax=5] 
  \spirographlike{20}    
\end{tikzpicture} 

\end{document} 
10
  • 2
    Sweet sweet sweet.....love TikZ.....love it <3.
    – azetina
    Commented Mar 2, 2012 at 16:53
  • Adding \noindent before \begin{tikzpicture} eliminates the overfull \hbox warning. Commented Mar 2, 2012 at 17:12
  • Thanks Peter I forget always these kind of problem, because I'm obsessed with the main question. Possible \usepackage{fullpage} Commented Mar 2, 2012 at 17:31
  • Very nice. This is getting closer and closer to the Spirograph question.
    – percusse
    Commented Mar 2, 2012 at 17:43
  • @percusse Can you provide any insights in generating the border like guilloche? Or may be with your knowledge on your post quoted above can the image sample I provided be recreated?
    – azetina
    Commented Mar 2, 2012 at 17:49
18

So here's an approach to draw the 'straight' parts. (Might be a bit crude to more seasoned people...)

The compile time is certain to put the most patient of us to test, but that's to be expected with TikZ doing such things... :)

I only plotted one such sample from the ones I found at Mathworld. So there are some samples ready to be downloaded. They are (as you can see below) a sum of lots of sines and the essential trick to get them to mesh together beautifully is to control the 'frequency' and the 'initial phase'.

So here's the code:

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[very thin]

\foreach \n in {0,...,19}
    {
        \foreach \x [remember=\x as \lastx (initially 0)] in {0.01,0.02,...,6.28}
            {
                \draw [red] (\lastx*2,{(4+sin(5*(180*\lastx/pi)))+((7+sin(7*(180*\lastx/pi)))-(4+sin(5*(180*\lastx/pi))))*(1+sin(5*(180*\lastx/pi)+\n*20))/2}) -- (\x*2,{(4+sin(5*(180*\x/pi)))+((7+sin(7*(180*\x/pi)))-(4+sin(5*(180*\x/pi))))*(1+sin(5*(180*\x/pi)+\n*20))/2});
            }
    }

\end{tikzpicture}

\end{document}

As you can see, I had to rescale a bit the coordinates, primarily because the source formulas used radians and TikZ likes degrees... Also I stretched a bit the thing along the x axis for looks.

And this is what you get after - well - a while:

enter image description here

Faster Code:

The idea is to reuse the previous coordinate instead of recomputing it with the use of \lastx. Further this means that there will only be {0,...,19} draw commands instead of 20\times6.29/0.01=12580.
This feature is used by doing an inline for-loop.

So instead you would do:

\begin{tikzpicture}[very thin]

  \foreach \n in {0,...,19} {
      \draw [red] (0,{(4+sin(5*(0)))+((7+sin(7*(0)))-(4+sin(5*(0))))*(1+sin(5*(0)+\n*20))/2}) 
      \foreach \x in {0.01,0.02,...,6.28} { 
          -- (\x*2,{(4+sin(5*(180*\x/pi)))+((7+sin(7*(180*\x/pi)))-(4+sin(5*(180*\x/pi))))*(1+sin(5*(180*\x/pi)+\n*20))/2}) 
      }; % <- Here the \draw ends
  }
\end{tikzpicture}

For further speed the computation of the angles could be made more explicit, and shorter expression could be made:

\begin{tikzpicture}[very thin]
  \foreach \n in {0,...,19} {
      \draw [red] (0,{4+(7-4)*(1+sin(\n*20))/2}) 
      \foreach \x in {0.5,1,...,360} { 
          -- ({6.28318*\x/180},{4+sin(5*\x)+(7+sin(7*\x)-(4+sin(5*\x)))*(1+sin(5*\x+\n*20))/2})
      };
  }
\end{tikzpicture}

As a last optimization all variables that can be reduced should be, this will not give as much, as it is simple multiplication and division:

\begin{tikzpicture}[very thin]
  \foreach \n [evaluate={\n*20} as \ntwenty] in {0,...,19} {
      \draw [red] (0,{5.5+1.5*sin(\ntwenty))}) 
      \foreach \x [evaluate={sin(5*\x)} as \sfx] in {0.5,1,...,360} { 
          -- ({0.034906585039886591*\x},{4+\sfx+(3+sin(7*\x)-\sfx)*(1+sin(5*\x+\ntwenty))/2})
      };
  }
\end{tikzpicture}

And actually it does compiler twice as fast, and faster for the last, when changing from evaluate to \pgfextra\pgfmathparse{sin(5*\x)}\edef\sfx{\pgfmathresult}\endpgfextra there is no gain, so is not showed:

  1. 1m59.699s
  2. 0m59.100s
  3. 0m43.627s
  4. 0m38.714s
6
  • Excellent results. I suppose one can make it into border like with the above. Though the compilation may take long one can export it as a pdf and then import it as a background.
    – azetina
    Commented Mar 3, 2012 at 1:02
  • 1
    Very nice, the compilation time will be speed up a lot by not calculating every point twice, so instead do: \draw [red] (\lastx*2,{(4+sin(5*(180*\lastx/pi)))+((7+sin(7*(180*\lastx/pi)))-(4+sin(5*(180*\lastx/pi))))*(1+sin(5*(180*\lastx/pi)+\n*20))/2}) \foreach \x in {0.01,0.02,...,6.28} { -- (\x*2,{(4+sin(5*(180*\x/pi)))+((7+sin(7*(180*\x/pi)))-(4+sin(5*(180*\x/pi))))*(1+sin(5*(180*\x/pi)+\n*20))/2}) }; also the 180*\x/pi could be automated in the for loop instead!
    – nickpapior
    Commented Mar 5, 2012 at 8:33
  • @zeroth: I'm sorry, I don't really get it... Where do I insert that line of code? What should I do with \lastx? I'd rather you edited my answer (if it's too much for a comment).
    – Count Zero
    Commented Mar 5, 2012 at 22:52
  • 1
    @CountZero I have edited your answer with two speedups! :)
    – nickpapior
    Commented Mar 6, 2012 at 7:14
  • @CountZero and one more, which only is to illustrate that the fewest repetitive computations is the best! :)
    – nickpapior
    Commented Mar 6, 2012 at 11:53
5

An alternative to creating guillochés with TikZ is to use a third-party tool to produce them as graphics files, and then import them into your document using the usual \includegraphics{…}.

I'm aware of the following guilloché tools:

GuardSoft Cerberus

A sophisticated, proprietary guilloché tool for Microsoft Windows that can export to PostScript. Prices are not listed on the website, though I gather that it's very expensive (thousands of dollars).

Screenshot of GuardSoft Cerberus

Excentro

Another proprietary Guilloché generator, available for $500 for Mac OS. There is also a "Lite" version available for $25. Bitmap and PDF outputs are supported.

Screenshot of Excentro

Guilloché Pattern Generator

A free-as-in-beer Adobe Flash application that you can use from a web browser. You simply select the desired foreground and background colours and adjust a series of sliders to control the size and shape of the pattern. The patterns can be saved as JPEG images by pressing S. If your system has a printer driver that outputs PDF files, then you can supposedly print vectorized PDFs by right-clicking and selecting "Print Guilloche". (I haven't tested this myself.)

Screenshot of subblue's Guilloché Pattern Generator

Vectorizer

A reimplementation of subblue's Guilloché Pattern Generator in HTML and JavaScript. It can output the image as a PNG or SVG graphic. (You can then use your favourite graphics converter, such as Inkscape or rsvg, to convert the SVG to PDF or EPS for use with LaTeX.)

Screenshot of Vectorizer

You must log in to answer this question.

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