Example: Arithmetic of the clock

Published 2011-12-22 | Author: Juan Luis Varona

This example shows the products i times j for i and j from 0 to 11 by using arithmetic modulo 12, i.e., the so called arithmetic of the clock.

The results of the products are represented both by the color of the clock and by the hand.

Download as: [PDF] [TEX]

Arithmetic of the clock

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Arithmetic of the clock
% Author: Juan Luis Varona
% http://www.unirioja.es/cu/jvarona/
% Colors:
\definecolor{clock0}{cmyk}{1,0,0,0} % cyan
\definecolor{clock4}{cmyk}{0,1,0,0} % magenta
\definecolor{clock8}{cmyk}{0,0,1,0} % yellow
  % \filldraw [fill=#3, line width=1.6pt] (0,0) circle (1cm); % simple fill (unused)
  % \draw[fill] (0,0) circle (1mm); % border (unused)
  \shadedraw [inner color=#3!30!white, outer color=#3!90!black, 
    line width=1.6pt] (0,0) circle (1cm); % disk with shadow and border
  \foreach \angle in {0, 30, ..., 330} 
    \draw[line width=1pt] (\angle:0.82cm) -- (\angle:1cm);
  \foreach \angle in {0,90,180,270}
    \draw[line width=1.3pt] (\angle:0.75cm) -- (\angle:1cm);
  \draw[line width=1.6pt] (0,0) -- (90-30*#4:0.6cm); % the hand 
% Default on latex.ltx: \fboxsep = 3pt \fboxrule = .4pt
\fboxsep = 3pt \fboxrule = 1.5pt 
\begin{scope}[line cap=round]
\foreach \i in {0,...,11}
  \foreach \j in {0,...,11} {
    % We use round by caution, because we are getting real numbers
    % \pgfmathresult = 3.0 gives itimesj = 3


Adding comments is currently not enabled.