Example: Rotated squares

Published 2007-02-23 | Author: Alain Matthes

A beautiful, but slightly psychedelic pattern. Note how commands from the ifthen package have been used to alternate between black and red squares.

Author:Alain Matthes

Download as: [PDF] [TEX]

Rotated squares

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.

\documentclass{article}
\usepackage{tikz,ifthen}
\begin{document}
\thispagestyle{empty}


\begin{tikzpicture}
    % Specify the initial square
    \path (0,0) coordinate (A) (12,0) coordinate (B)
          (12,12) coordinate (C) (0,12) coordinate (D);
    \foreach \i in {1,...,14}{
        \ifthenelse{\isodd{\i}}{\def\couleur{black}}{\def\couleur{red}}
        \draw[fill=\couleur] (A)--(B)--(C)--(D)--cycle; 
        \path (A) coordinate (TMP);
        \path (A)--(B) coordinate[near end] (A)
                 --(C) coordinate[near end] (B)
                 --(D) coordinate[near end] (C)
                 --(TMP) coordinate[near end] (D);
    }
\end{tikzpicture}


\end{document}

Comments

Adding comments is currently not enabled.