Advertisement
Pi-Nerd

Sierpinski TikZ

Nov 4th, 2021
2,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 0.57 KB | None | 0 0
  1. \documentclass[multi=tikzpicture]{standalone}
  2. \usepackage{tikz}
  3.  
  4. \newcommand{\sier}[1]{
  5.  \fill[white,draw=black,line join=bevel] (30:1) -- (150:1) -- (270:1) -- cycle;
  6.  \node[red,transform shape] at (0,0) {#1};
  7.  \ifnum#1>0
  8.    \foreach \theta in {90,210,330}
  9.    {
  10.      \begin{scope}[shift={(\theta:1)},scale=0.5]
  11.        \expandafter\sier\expandafter{\the\numexpr#1-1\relax}
  12.      \end{scope}
  13.    }
  14.  \fi
  15. }
  16.    
  17. \begin{document}
  18.  
  19. \begin{tikzpicture}
  20.  \fill[green,draw=black] (90:2) -- (210:2) -- (330:2) -- cycle;
  21.  \sier4
  22. \end{tikzpicture}
  23.  
  24. \end{document}
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement