Compilateur LaTeX en ligne
www.cpierquet.fr
fichiers/test/tkztampon.tex
↓ télécharger
%!TEX pdflatex
% !TeX TXS-program:compile = txs:///arara
% arara: pdflatex: {shell: no, synctex: no, interaction: batchmode}

\documentclass{article}
\usepackage[margin=5mm,a4paper]{geometry}
\usepackage{tikz,simplekv,ifthen,xstring}
\usetikzlibrary{calc,shapes}
\usepackage{calc}

\makeatletter
\newsavebox\tmpmystampbox
\newlength\rayon@tampon@approuve
\newlength\largeur@texte@vstretch@tampon@approuve
\setlength\rayon@tampon@approuve{2cm}
\colorlet{couleurtampon}{black}

\defKV[TamponApprouve]{%
	Rayon=\setlength\rayon@tampon@approuve{#1},%
	Couleur=\colorlet{couleurtampon}{#1},%
	Rotation=\def\rotation@tampon@approuve{#1},%
	Police=\def\police@tampon@approuve{#1}
}
\setKVdefault[TamponApprouve]{%
	Rayon=2cm,%
	Couleur=black,%
	Rotation=20,%
	Police=\bfseries\sffamily
}

\tikzstyle{stampstars}=[star,star points=5,star point ratio=2.25]%

\newcommand\intstampstar[4][0]{%1 = rotate, %2=pos, %3 = big radius, %4 = small radius
	\begin{scope}[shift={#2},rotate=#1]
		\draw[stampstars,rounded corners=0.02\rayon@tampon@approuve,line width=0.02\rayon@tampon@approuve] 
		(0:#3\rayon@tampon@approuve) -- 
		(36:#4\rayon@tampon@approuve) -- 
		(72:#3\rayon@tampon@approuve) -- 
		(108:#4\rayon@tampon@approuve) -- 
		(144:#3\rayon@tampon@approuve) -- 
		(180:#4\rayon@tampon@approuve) -- 
		(216:#3\rayon@tampon@approuve) -- 
		(252:#4\rayon@tampon@approuve) -- 
		(288:#3\rayon@tampon@approuve) -- 
		(324:#4\rayon@tampon@approuve) -- 
		cycle;
	\end{scope}
}

\newcommand\inttamponapprouve{%
	%bordure grande
	\draw[line width=0.05\rayon@tampon@approuve,line cap=round] (25:0.975\rayon@tampon@approuve) arc(25:155:0.975\rayon@tampon@approuve) ;
	\draw[line width=0.05\rayon@tampon@approuve,line cap=round] (-25:0.975\rayon@tampon@approuve) arc(-25:-155:0.975\rayon@tampon@approuve) ;
	%bordure petite
	\draw[line width=0.02\rayon@tampon@approuve,line cap=round] (27:0.875\rayon@tampon@approuve) arc(27:153:0.875\rayon@tampon@approuve) ;
	\draw[line width=0.02\rayon@tampon@approuve,line cap=round] (-27:0.875\rayon@tampon@approuve) arc(-27:-153:0.875\rayon@tampon@approuve) ;
	%grand rectangle
	\draw[rounded corners=0.15\rayon@tampon@approuve,line width=0.05\rayon@tampon@approuve,line cap=round] (0.95\rayon@tampon@approuve,-0.3\rayon@tampon@approuve) -| (1.2\rayon@tampon@approuve,0.3\rayon@tampon@approuve) -| (-1.2\rayon@tampon@approuve,-0.3\rayon@tampon@approuve) -- (0.66\rayon@tampon@approuve,-0.3\rayon@tampon@approuve);
	\draw[line width=0.05\rayon@tampon@approuve,line cap=round] (0.75\rayon@tampon@approuve,-0.3\rayon@tampon@approuve)--++(0.075\rayon@tampon@approuve,0) ;
	%petit rectangle
	\draw[rounded corners=0.1\rayon@tampon@approuve,line width=0.02\rayon@tampon@approuve] (1.125\rayon@tampon@approuve,0.225\rayon@tampon@approuve) rectangle (-1.125\rayon@tampon@approuve,-0.225\rayon@tampon@approuve) ;
	%étoiles haut
	\intstampstar[18]{(0,0.6\rayon@tampon@approuve)}{0.15}{0.06}
	\intstampstar[18]{(0.2\rayon@tampon@approuve,0.575\rayon@tampon@approuve)}{0.12}{0.05}
	\intstampstar[18]{(-0.2\rayon@tampon@approuve,0.575\rayon@tampon@approuve)}{0.12}{0.05}
	%étoiles bas
	\intstampstar[54]{(0,-0.6\rayon@tampon@approuve)}{0.15}{0.06}
	\intstampstar[54]{(0.2\rayon@tampon@approuve,-0.575\rayon@tampon@approuve)}{0.12}{0.05}
	\intstampstar[54]{(-0.2\rayon@tampon@approuve,-0.575\rayon@tampon@approuve)}{0.12}{0.05}
	%le texte, de largeur maximale 1.95\rayon@tampon@approuve et hauteur maximale 0.375\rayon@tampon@approuve
	\begin{scope}
		\clip (1.125\rayon@tampon@approuve,0.225\rayon@tampon@approuve) rectangle (-1.125\rayon@tampon@approuve,-0.225\rayon@tampon@approuve) ;
		\ifthenelse{\largeur@texte@vstretch@tampon@approuve < \dimexpr1.95\rayon@tampon@approuve\relax}%
		{%
			\draw (0,0) node[inner sep=0pt] {\resizebox*{!}{0.375\rayon@tampon@approuve}{\police@tampon@approuve\vphantom{qÉ}\texte@tampon@approuve}} ;
		}%
		{%
			\draw (0,0) node[inner sep=0pt] {\resizebox*{1.95\rayon@tampon@approuve}{!}{\police@tampon@approuve\vphantom{qÉ}\texte@tampon@approuve}} ;
		}%
	\end{scope}
}

\NewDocumentCommand\TamponApprouve{ s O{} D<>{} m }{%
	\restoreKV[TamponApprouve]%
	\setKV[TamponApprouve]{#2}%
	\if\relax\detokenize{#4}\relax%
		\def\texte@tampon@approuve{APPROUVÉ}%
	\else%
		\def\texte@tampon@approuve{#4}%
	\fi%
	%gestion de la mise à l'échelle...
	\savebox{\tmpmystampbox}{\resizebox*{!}{0.375\rayon@tampon@approuve}{\police@tampon@approuve\vphantom{qÉ}\texte@tampon@approuve}}%
	%\usebox{\tmpmystampbox}%
	\settowidth\largeur@texte@vstretch@tampon@approuve{\usebox{\tmpmystampbox}}%
	%position normale ou absolue...
	\IfBooleanTF{#1}%
		{%
			\begin{tikzpicture}[overlay,remember picture,shift={#3},couleurtampon,rotate=\rotation@tampon@approuve,transform shape]%
				\inttamponapprouve
			\end{tikzpicture}%
		}%
		{%
			\begin{tikzpicture}[#3,couleurtampon,rotate=\rotation@tampon@approuve,transform shape]%
				\inttamponapprouve
			\end{tikzpicture}%
		}%
}
\makeatother

\usepackage{codehigh}

\begin{document}

\begin{demohigh}[language=latex/latex2]
\TamponApprouve{}%
\TamponApprouve[Couleur=blue!50!black]{VALIDÉ}
\end{demohigh}

\begin{demohigh}[language=latex/latex2]
\TamponApprouve[Rayon=1.5cm,Rotation=0]{}%
\TamponApprouve[Rayon=1.5cm,Rotation=-15,Couleur=red]{CERTIFIÉ}
\end{demohigh}

\begin{demohigh}[language=latex/latex2]
\TamponApprouve%
  [Rayon=1cm,Police=\ttfamily\bfseries,Couleur=green!50!black]%
  {FÉLICITATIONS}%
\end{demohigh}


\vspace*{5cm}

\begin{codehigh}[language=latex/latex2]
\TamponApprouve*%
  [Rayon=1.25cm,Couleur=pink]%
  < ([xshift=-2.5cm,yshift=2.5cm]current page.south east) >%
  {CHAPITRE 01}%
\end{codehigh}

\TamponApprouve*%
  [Rayon=1.25cm,Couleur=pink!50!black]%
  < ([xshift=-2.5cm,yshift=2.5cm]current page.south east) >%
  {CHAPITRE 01}%
\end{document}