Skip to content

Rotate Triangle

Rotate_tr
View Comments

Some explanations about this code :

Rendered code
View TeX code
% !TEX TS-program = lualatex
\documentclass[border=12pt]{standalone}
\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage[mini]{tkz-euclide}
\usepackage{tkz-elements}
\begin{document} 
  
\directlua{dofile("rotate_tr.lua")}
  
\begin{tikzpicture}
\tkzGetNodes
\foreach \density in {20,30,...,240}{
   \tkzDrawPolygon[fill = MidnightBlue!\density](A,B,C)
   \directlua{new_triangle()}
   \tkzGetNodes
   }
\end{tikzpicture}
\end{document}
View Lua code
init_elements()
z.A = point(0, 0)
z.B = point(12, 0)
z.C = line(z.A, z.B):equilateral().pc
function new_triangle()
  local x = z.A
  z.A = line(z.A, z.B):point(.15)
  z.B = line(z.B, z.C):point(.15)
  z.C = line(z.C, x):point(.15)
end