51

There are examples of how to make nice circular logos in Calligraphic logo in tikz and Recreating a logo (text around a circle), but I'm looking to mimic the impression with a traditional rubber stamp.

That is, transform a perfect LaTeX logo in a stamp with evident random imperfections, including fading (usual in hand rubber stamps) blur appearance and may be even a little shape distortion. For example, instead of the this image, I want obtain something like this:

MWE

Of course, this is an easy work for The Gimp or another image manipulation program for just one stamp, but for a regular use of stamps with dynamic contents (for example with \today) is preferable a pure LaTeX solution.

Edit: extended question in Toward a Stamper Package

6
  • 2
    Possible inspiration: the coffee4 package.
    – yo'
    Commented Jan 31, 2013 at 0:20
  • 1
    Other possible inspiration: tex.stackexchange.com/a/74107/14500. Commented Jan 31, 2013 at 0:32
  • Not pure TeX, but stretching an image with a transparent & white gradient / pattern and overlaying it should do the job.
    – Xavier
    Commented Jan 31, 2013 at 0:48
  • 1
    I was thinking you can rotate a second stamp slightly (e.g. 2 degrees) and overlay it on itself. This might mimic typical problem of hand motion on old stamps!
    – Pouya
    Commented Jan 31, 2013 at 14:22
  • @Pouya, I also thought of that solution. In fact, the idea of simulating a stamp came from simulate an old typewriter with three layers of text on this question. But have multiple overlapping TikZ pictures seems excessive. Maybe it is possible similate with a smooth shadow like those of the 'pst-blur' package or another more simpler way.
    – Fran
    Commented Jan 31, 2013 at 18:10

1 Answer 1

42

Second Version

A version via a simple functional shading (no random values...)

Extract from pgfmanual: Warning: These shadings are the least portable of all and they put the heaviest burden of the renderer. They are slow and, possibly, will not print correctly!

The picture below is a screenshot from AdobeReader (ImageMagick, evince, xpdf, okular produce bad results).

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{fadings,patterns,fit}

% use stamp.png to make a fading (a mask)
\begin{tikzfadingfrompicture}[name=stamp]
  \node [fill=transparent!0,inner sep=0]
  {\includegraphics[width=50pt,height=50pt]{stamp.png}};
  \begin{scope}[yshift=-90pt,transform canvas={scale=.2}]
    \node[color=gray!50!black,font=\ttfamily] {\today};
  \end{scope}
\end{tikzfadingfrompicture}

\colorlet{mycolor}{blue}
\pgfdeclarefunctionalshading{stampfunctional}
{\pgfpointorigin}{\pgfpoint{4cm}{4cm}}{\pgfshadecolortorgb{mycolor}{\myrgb}}{
  20 mul
  sin 1 add 0.5 mul
  exch
  20 mul
  cos 1 add 0.5 mul
  add 0.5 mul
  %1 exch sub
  dup \myrgbred
  1 exch sub mul 1 exch sub exch
  dup \myrgbgreen
  1 exch sub mul 1 exch sub exch
  \myrgbblue
  1 exch sub mul 1 exch sub
}

\begin{document}
\begin{tikzpicture}[inner sep=0]
  \colorlet{mycolor}{blue!70!black}
  % fill a region stampshading
  \node[
  shading=stampfunctional,
  shading angle=-45,
  minimum width=4cm,minimum height=4cm]{};
  % fade the same region using stamp fading as mask
  \node[fill=white,minimum width=4cm,minimum height=4cm,path fading=stamp]{};

  \colorlet{mycolor}{lime!70!black}
  % fill a region stampshading
  \node[
  shading=stampfunctional,
  shading angle=-45,
  minimum width=4cm,minimum height=4cm] at (0,4){};
  % fade the same region using stamp fading as mask
  \node[fill=white,minimum width=4cm,minimum height=4cm,path fading=stamp] at (0,4){};
\end{tikzpicture}
\end{document}

First version

The blur effect can't be made via PDF. But with fading and shading, you can simulate some imperfections.

Here is an example using stamp.png (your image in black and transparent color):

enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{fadings,patterns,fit}

% use stamp.png to make a fading (a mask)
\begin{tikzfadingfrompicture}[name=stamp]
  \node [fill=transparent!0,inner sep=0]
  {\includegraphics[width=50pt,height=50pt]{stamp.png}};
  \begin{scope}[yshift=-90pt,transform canvas={scale=.2}]
    \node[color=gray!50!black,font=\ttfamily] {\today};
  \end{scope}
\end{tikzfadingfrompicture}

\pgfdeclarehorizontalshading[mycolor]{stampshading}
  {4cm}{
    color(0cm)=(mycolor);
    color(1cm)=(mycolor);
    color(1.35cm)=(mycolor);
    color(1.40cm)=(white!80!mycolor);
    color(1.45cm)=(mycolor);
    color(1.85cm)=(mycolor);
    color(2.00cm)=(white!80!mycolor);
    color(2.05cm)=(mycolor);
    color(2.25cm)=(mycolor);
    color(2.30cm)=(white!80!mycolor);
    color(2.35cm)=(mycolor);
    color(2.45cm)=(mycolor);
    color(2.50cm)=(white!80!mycolor);
    color(2.55cm)=(mycolor);
    color(4cm)=(mycolor)
  }


\begin{document}
\begin{tikzpicture}[inner sep=0]
  \colorlet{mycolor}{blue!70!black}
  % fill a region stampshading
  \node[
  shading=stampshading,
  shading angle=-45,
  minimum width=4cm,minimum height=4cm]{};
  % fade the same region using stamp fading as mask
  \node[fill=white,minimum width=4cm,minimum height=4cm,path fading=stamp]{};

  \colorlet{mycolor}{lime!70!black}
  % fill a region stampshading
  \node[
  shading=stampshading,
  shading angle=-45,
  minimum width=4cm,minimum height=4cm] at (0,4){};
  % fade the same region using stamp fading as mask
  \node[fill=white,minimum width=4cm,minimum height=4cm,path fading=stamp] at (0,4){};
\end{tikzpicture}
\end{document}

The shading is a simple horizontal shading. With a functional shading, the imperfections could be more realist.

Here the stamp.png image (but without transparent color):

enter image description here

1

You must log in to answer this question.

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