Example: Rotated polygons

Published 2012-02-26 | Author: Ismael Gutierrez Garcia

Extending the rotated triangle example by Alain Matthes, here are rotated hexagons, pentagons and squares.

Download as: [PDF] [TEX]  •  [Open in writeLaTeX]

Rotated polygons

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.

% Rotated polygons
% Author: Dr. rer. nat. Ismael Gutierrez Garcia
\documentclass{article}
\usepackage[usenames,dvipsnames,pdftex]{xcolor}
\usepackage{tikz}
\usepackage{ifthen}
\begin{document}
\newcounter{density}
\setcounter{density}{20}
\begin{tikzpicture}
    \def\couleur{BlueGreen}
    \path[coordinate] (0,0)  coordinate(A)
                ++( 120:6cm) coordinate(B)
                ++(60:6cm) coordinate(C)
                ++(0:6cm) coordinate(D)
                ++(-60:6cm) coordinate(E)
                ++(240:6cm) coordinate(F)
                ;
    \draw[fill=\couleur!\thedensity] (A) -- (B) -- (C) --(D) -- (E) -- (F)-- cycle;
    \foreach \x in {1,...,40}{%
        \pgfmathsetcounter{density}{\thedensity+10}
        \setcounter{density}{\thedensity}
        \path[coordinate] coordinate(X) at (A){};
        \path[coordinate] (A) -- (B) coordinate[pos=.10](A)
                            -- (C) coordinate[pos=.10](B)
                            -- (D) coordinate[pos=.10](C)
                            -- (E) coordinate[pos=.10](D)
                             -- (F) coordinate[pos=.10](E)
                            -- (X) coordinate[pos=.10](F);
        \draw[fill=\couleur!\thedensity] (A)--(B)--(C)-- (D) --(E) -- (F) -- cycle;
    }
\end{tikzpicture}

\setcounter{density}{20}
\begin{tikzpicture}
    \def\couleur{LimeGreen}
    \path[coordinate] (0,0)  coordinate(A)
                ++( 144:10cm) coordinate(B)
                ++(72:10cm) coordinate(C)
                ++(0:10cm) coordinate(D)
                ++(-72:10cm) coordinate(E)
                                ;
    \draw[fill=\couleur!\thedensity] (A) -- (B) -- (C) --(D) -- (E) --  cycle;
    \foreach \x in {1,...,40}{%
        \pgfmathsetcounter{density}{\thedensity+10}
        \setcounter{density}{\thedensity}
        \path[coordinate] coordinate(X) at (A){};
        \path[coordinate] (A) -- (B) coordinate[pos=.10](A)
                            -- (C) coordinate[pos=.10](B)
                            -- (D) coordinate[pos=.10](C)
                            -- (E) coordinate[pos=.10](D)
                             -- (X) coordinate[pos=.10](E);
        \draw[fill=\couleur!\thedensity] (A)--(B)--(C)-- (D) --(E)  -- cycle;
    }
\end{tikzpicture}

\setcounter{density}{20}
\begin{tikzpicture}
    \def\couleur{OrangeRed}
    \path[coordinate] (0,0)  coordinate(A)
                ++( 90:12cm) coordinate(B)
                ++(0:12cm) coordinate(C)
                ++(-90:12cm) coordinate(D);
    \draw[fill=\couleur!\thedensity] (A) -- (B) -- (C) --(D) -- cycle;
    \foreach \x in {1,...,40}{%
        \pgfmathsetcounter{density}{\thedensity+20}
        \setcounter{density}{\thedensity}
        \path[coordinate] coordinate(X) at (A){};
        \path[coordinate] (A) -- (B) coordinate[pos=.10](A)
                            -- (C) coordinate[pos=.10](B)
                            -- (D) coordinate[pos=.10](C)
                            -- (X) coordinate[pos=.10](D);
        \draw[fill=\couleur!\thedensity] (A)--(B)--(C)-- (D) -- cycle;
    }
\end{tikzpicture}
\end{document}

Comments

  • #1 Dror Atariah, February 26, 2012 at 4:49 p.m.

    Very nice! Is it possible to implement this as a function, depending on the number of vertices and the color?

Adding comments is currently not enabled.

There are currently one comments on this entry.

Features
Tags
Scientific and technical areas
Other areas

Creative Commons License