-- TriFractal.lua

            -- This is a simple fractal I came up with to get started.

win = openwindow ("Hexagon",-1,-1,1000,700)
setactivewindow (win)

textsize(2)
backcolor (0,0,0,255)

--cls()   
Pi2=6.28318 ; Type = 3 ; Count = 0
 Ang1 = Pi2/Type ; Ang = 0 ; x = 150 ; y = 650
 color (255,0,0,255)


 function RotateLeft()
      Ang = Ang + Ang1
      if Ang > Pi2 then
       Ang = Ang - Pi2
   end
   
 end
 function MoveSteps ( distance )
        dx = cos(Ang) * distance
        dy = sin(Ang) * distance
        x2 = x + dx
        y2 = y - dy
        line( x,y,x2,y2)
        x = x2 ; y = y2
 end   
 function Fractal(size)
         local    cnt = 0
          Ang1 = Pi2/Type
          Count = Count + 1
          while cnt < 3
          do                
             MoveSteps ( size )
             RotateLeft()
             cnt = cnt + 1
               if size > 10 then
                  Fractal(size/2)
               end
              
          end
 end


color (0,0,255,255)       
 Fractal(700)
drawtext("Press any key to exit ..",0,0)
sync()

key=inkey()
closewindow(win)             -- This ends the program.
closeapplication

 

Make a free website with Yola