--  This program written by    Rick3137 

      --  http://rb23.yolasite.com/


pendown = 0  cnt = 0  PenX = 0  PenY = 0  Angle2 = 0  x2 = 0  y2 = 0  dx = 0

 dy = 0 Angle3 = 0 Angle4 =0 test = 0 d = 0 cnt2 = 0 red =0 green = 0 blue = 0

 key = 0 x1 =0  y1=0

                -- Create functions at start of program

                -- 1 Radian = 57.2958 Degrees.

                -- 1 degree = .0174532925 Radians

                -- math degrees = 450 - compass

function SetColor() color (red,green,blue) end

function ChangeColor(n)

    blue = blue + n

    if blue > 255 then blue =50 ; green = green + 1 end

    if green > 255 then green = 50 ; red = red + 1 end

    if red > 255 then green = 0 ; red = 50 blue = 0 end

    color (red,green,blue)

 end

function GotoXY(x,y)  PenX = x ; PenY = y end

function RotateRight(n)

         Angle = Angle + n


               if  Angle > 360  then  Angle = Angle - 360   end

               if Angle == 360 then Angle = 0 end



end

function RotateLeft(n)

         if  Angle == n  then Angle = 0  n = 0 end

         if Angle > n  then

         Angle = Angle - n


         else  Angle = n - Angle  Angle = 360 - Angle


         end






end

function RadianToDegree(n) return n * 57.2958 end

function DegreeToRadian(n) return n * .0174532925 end

function GetAngle (n)   -- A function starts with "function" and ends with "end"

    n = 450 - n

    if n == 450 then n = 90 end

    if n > 450 then n = n - 360 end


    return n

end

 function MoveSteps (n)                 -- move n steps using Angle

     x1 = 500 + PenX

     y1 = 300 - PenY

     Angle2 = GetAngle ( Angle )        -- The reason for all of this is because

     Angle3 = DegreeToRadian ( Angle2 ) --  I am converting angles from another language that

     dx = cos (Angle3)                   -- uses a turtle graphics type system. " Scratch "

     dy = sin (Angle3)

     x2 = x1 + dx * n

     y2 = y1 - dy * n

     if pendown == 1 then line(x1,y1,x2,y2) end

     PenX = PenX + dx * n   PenY = PenY + dy * n

 end


 function test( a1,a2)         -- Use for debugging

       MoveSteps (100)  RotateLeft(90)  MoveSteps (100)   RotateLeft(90)  MoveSteps (100)  RotateLeft(90)  MoveSteps (100)  RotateLeft(90)

        MoveSteps (100)  RotateLeft(90)  MoveSteps (100)

      drawtext( 50,40,"lp,st ")  drawtext(200,40,"                " ) drawtext(210,40,a1 )    drawtext(350,40,"              ")    drawtext(370,40,a2 )

      drawtext(50,60,"lp,st ")     drawtext(200,60,"     ")    drawtext(350,60,"      ")   drawtext(200,60,lp)    drawtext(350,60,st)

      drawtext(50,80,"PenX,PenY ")     drawtext(200,80,"      ")    drawtext(350,80,"       ")  drawtext(200,80, PenX )    drawtext(350,80, PenY )

      drawtext (50,100, Angle )

      drawtext (50,120, Angle2 )



  end

  function Fractal ( Loop , Distance )

   local cnt = 0

if Loop > 0 then


            while cnt < c2

            do


                MoveSteps ( Distance/5 )

       RotateRight( 90 )

                MoveSteps ( Distance* .40 )

                Fractal (Loop - 1 , Distance /2)

                MoveSteps ( Distance* .40 )

                RotateLeft(90)

                MoveSteps ( Distance/3 )

                RotateRight( 90 )


                MoveSteps ( Distance/5 )  Fractal (Loop - 1 , Distance /3)

                RotateRight( 90 )

                MoveSteps ( Distance/3 )

                RotateLeft(90)


                MoveSteps ( Distance/3 )

                RotateRight( 90 )

                MoveSteps ( Distance/5 )   Fractal (Loop - 1 , Distance /3)

                RotateRight( 90 )

                MoveSteps ( Distance/3 )

                RotateLeft(90)


                MoveSteps ( Distance/3 )

                RotateRight( 90 )

                MoveSteps ( Distance/5 )   Fractal (Loop - 1 , Distance /3)

                RotateRight( 90 )

                MoveSteps ( Distance/3 )

                RotateLeft(90)

                MoveSteps ( Distance* .40 )

                Fractal (Loop - 1 , Distance /2)

                MoveSteps ( Distance* .40 )

                RotateRight( 90 )


                cnt = cnt + 1

                RotateRight( 90 )

            end

         Loop = Loop - 1

end

   ChangeColor(10)

   end


      -- Starts Program

      screen (1200,700,32," Fuzzy Fractals ")


      d = 200  c1 = 4  c2 = 4    Angle = 270

      PenX = 0  PenY =-100

      color (100,100,200)

      backcolor (0,0,20)

      clearscreen()

      redraw()

      pendown = 1

      Fractal( c1 , d )    redraw() inkey() clearscreen() redraw()





      closewindow()     -- This ends the program.



















 

Make a free website with Yola