-- by Rick3137   http://rb23.yolasite.com
 
win = openwindow ("Hexagon",-1,-1,1000,700)
setactivewindow (win)

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

--cls()   
p2=6.28318530 ; Type = 8 ; Count = 0
 Ang1 = p2/Type ; Ang = 0 ; x = 300 ; y = 650 ; count = 1
 color (255,0,0,255)
function Fractal1( )
       local cnt = 0
       local Distance = 200

   while cnt < 8
      do
           SetColor(1)
           MoveSteps( Distance )
           RotateLeft( p2/8 )
     cnt = cnt + 1
     Fractal2( )
     end

end
function Fractal2( )
       local cnt = 0
       local Distance = 200

   while cnt < 4
       do
           SetColor(2)
           MoveSteps( Distance )
           RotateLeft( p2/4 )
     cnt = cnt + 1
     Fractal3( )
       end

end 

function Fractal3( )
       local cnt = 0
       local Distance = 200

   while cnt < 3
      do
           SetColor(3)
           MoveSteps( Distance )
           RotateLeft( p2/3 )
     cnt = cnt + 1
     Fractal4()
     end

end 

function Fractal4( )
       local cnt = 0
       local Distance = 100
  SetColor(4)
   while cnt < 3
       do
           MoveSteps( Distance )
           RotateLeft( p2/3 )
     cnt = cnt + 1
     Fractal5( )
      end
end 

function Fractal5( )
       local cnt = 0
       local Distance = 50
  SetColor(5)
   while cnt < 3
      do
           MoveSteps( Distance )
           RotateLeft( p2/3 )
     cnt = cnt + 1
     Fractal6( )
      end
end
 
 

    function Fractal6( )
       local cnt = 0
       local Distance = 25
  SetColor2(count)
   while cnt < 3
      do
           MoveSteps( Distance )
           RotateLeft( p2/3 )
     cnt = cnt + 1
     Fractal7( )
      end
   count = count + 1
   if count > 7 then
     count = 1
  end
end 

function Fractal7( )
       local cnt = 0
       local Distance = 12
   while cnt < 3
      do
           MoveSteps( Distance )
           RotateLeft( p2/3 )
     cnt = cnt + 1
      Fractal8( )
      end
end 

function Fractal8( )
       local cnt = 0
       local Distance = 6
        while cnt < 6
             do
              MoveSteps( Distance )
              RotateLeft( p2/3 )
        cnt = cnt + 1
          end

end 

  

  
 function SetColor(clr)

         if clr == 0 then
        color(255,255,255,255)
      end
        if clr == 1 then
        color(255,250,255,255)
     end
      if clr == 2 then
        color(0,255,255,255)
     end
      if clr == 3 then
        color(255,0,0,255)
     end
      if clr == 4 then
        color(0,255,0,255)
     end
      if clr == 5 then
        color(255,255,155,255)
     end
      if clr == 6 then
        color(180,200,255,255)
     end
      if clr == 7 then
        color(180,0,255,255)
     end 

 end
  function SetColor2(clr)

         if clr == 0 then
        color(200,200,255,255)
       end
        if clr == 1 then
        color(255,255,255,255)
     end
      if clr == 2 then
        color(0,255,255,255)
     end
      if clr == 3 then
        color(255,0,0,255)
     end
      if clr == 4 then
        color(255,0,0,255)
     end
      if clr == 5 then
        color(255,0,155,255)
     end
      if clr == 6 then
        color(255,200,255,255)
     end
      if clr == 7 then
        color(255,0,255,255)
     end 

 end 


 function RotateLeft(Angle)
      Ang = Ang + Angle
      if Ang > p2 then
      Ang = Ang - p2
   end
 end
 function MoveSteps ( distance )

       local dx = cos(Ang) * distance
       local dy = sin(Ang) * distance
       local x2 = x + dx
       local y2 = y - dy

        line( x,y,x2,y2)
        x = x2 ; y = y2
 end 


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

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


 
 

 

Make a free website with Yola