#!/bin/bash

TEX=texput.tex
rm -f $TEX

cat >>$TEX <<\EOF
\documentclass[a4paper]{article}
\usepackage[french]{babel}
\usepackage{beautiful}
\usepackage{tikz}
\usepackage{tkz-fct}
\usepackage{tkz-base}
\usepackage{tkz-euclide}
\usetikzlibrary{decorations.text}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}
\draw[thick,color=black] (0,0) circle (3.2);
\begin{scope}[scale=3.1]
\tkzDefPoint(0,0){O}
\tkzDefPoint(0.98,0){P}
\tkzClipCircle(O,P)
EOF

gp -fq >>$TEX <<\EOF
{
	default(realprecision, 5);
	for(i=3,5,
		M=2*i;
		for(j=0,M-1,
			z=4/3.1*exp(2*I*Pi*j/M)*(1-1/i);
			printf("\\tkzDefPoint(%.5f,%.5f){p%i%i}\n", real(z), imag(z), i, j);
		);
		for(j=0,M-1,
			printf("\\tkzDrawCircle[orthogonal through=p%i%i and p%i%i](O,P)\n", i, j, i, (j+1)%M);
		);
	);
}
EOF

cat >>$TEX <<\EOF
\end{scope}
\node at (-0.05,0.01) {
\fontsize{39}{0}\selectfont$\boldsymbol{\mathbb{
G\mkern-3mu
A\mkern-4mu
A\mkern-5mu
T\mkern-2mu
I
}}$};
\begin{scope}[yshift=-35mm]
\path[postaction={decorate,decoration={
                raise=-0.5ex,
                reverse path,
                text along path,
                text align/center,
                text={|\large\bfseries|E~A~3~8~9~3}
}}] (10:20mm) arc (10:170:20mm);
\end{scope}
\end{tikzpicture}
\end{document}
EOF

lualatex $TEX

pdfcrop -margins 1 texput{,0}.pdf
fatten texput{0,1}.pdf
fatten texput{1,2}.pdf
fatten texput{2,3}.pdf
pdfcrop texput{3,4}.pdf
mv texput4.pdf stamp.pdf
rm texput*

rm -f texput*
