From f5ce4795667f3bc5c7ae8e6da5e3497821fe545f Mon Sep 17 00:00:00 2001 From: Kenneth Odle Date: Sun, 30 Jul 2023 14:28:01 -0400 Subject: [PATCH] Added pentagon example --- pentagon.tex | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 pentagon.tex diff --git a/pentagon.tex b/pentagon.tex new file mode 100644 index 0000000..1fa2e22 --- /dev/null +++ b/pentagon.tex @@ -0,0 +1,40 @@ +\documentclass[]{article} + +\usepackage{tikz} +\usetikzlibrary{calc} + +% From https://tex.stackexchange.com/questions/308849/draw-regular-pentagon-in-tikz + +\begin{document} + +\newcommand{\downpent}[2][blue!50!gray,draw=white,thick]% [options], list of direction steps e.g {10/2/1/1} +{ +\coordinate (temp) at (0,0); +\foreach \p in {#2} +{ \foreach \s in \p + { \coordinate (temp) at ($(temp)+(\s*36-18:1)$); + } + \fill[#1] ($(temp)+(54:0.618)$) -- ($(temp)+(126:0.618)$) -- ($(temp)+(198:0.618)$) -- ($(temp)+(270:0.618)$) -- ($(temp)+(342:0.618)$) -- cycle; + \coordinate (temp) at (0,0); +} +} + \newcommand{\uppent}[2][blue!50!gray,draw=white,thick]% [options], list of coordinates e.g {1,2},{1,3},{4,2} +{ +\coordinate (temp) at (0,0); +\foreach \p in {#2} +{ \foreach \s in \p + { \coordinate (temp) at ($(temp)+(\s*36-18:1)$); + } + \fill[#1] ($(temp)+(-54:0.618)$) -- ($(temp)+(-126:0.618)$) -- ($(temp)+(-198:0.618)$) -- ($(temp)+(-270:0.618)$) -- ($(temp)+(-342:0.618)$) -- cycle; + \coordinate (temp) at (0,0); +} +} + +\begin{tikzpicture} +\downpent[orange,draw=white,thick]{{2},{4},{6},{8},{10},{10,1,10}} +\uppent[cyan!50!blue,draw=white,thick]{{},{10,1},{10,1,10,3},{10,1,10,1},{10,1,10,9},{10,1,10,7}} +\foreach \a [count=\c] in {18,54,...,342} \draw[->,thick] (0,0) -- (\a:1cm) node[label=\a:\c] {}; +\end{tikzpicture} + + +\end{document} \ No newline at end of file