--  This program written by  leszpio and  Rick3137 at

      --  Scratch.mit.edu


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 SetColor2(n)

         red = n * 10

         green = n * 12

         blue = n * 14



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 = 600 + PenX

     y1 = 350 - 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



      -- Starts Program

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


      n = 1  Angle = 270  AngleR = 120 k = 0  i = 6

      PenX = 0  PenY = 0 cnt = 0 cnt2 = 0 cnt3 = 0

      color (100,0,200)

      backcolor (0,0,20)

      clearscreen()

      redraw()

      pendown = 1

      while cnt < 6

      do

            clearscreen()

            redraw()

            k =  4 * n + 3

            cnt2 = 0

                 while cnt2 < 360/ i

                 do

                 cnt3 = 0

                       while cnt3 < k

                       do

                       MoveSteps(280)

                       RotateRight( 180 - 180 / k )

                       cnt3 = cnt3 + 1

                       redraw()

                       end

                 RotateLeft( i )

                 --ChangeColor( 200 )

                 SetColor2(cnt2)

                 cnt2 = cnt2 + 1

                 end

            wait(2000)

            i = i - 1

            n = n + 1

            cnt = cnt + 1

      end

      inkey()

      closewindow()     -- This ends the program.



















 

Make a free website with Yola