--  This program written by Auntiechristine and Rick3137 at

      --  Scratch.mit.edu

      --  See more programs like this at: http://rb23.yolasite.com/

screen (1000,600,32,"Template")     -- Starts Program

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 = 0 ; green = green + 1 end

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

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

    color (red,green,blue)

 end

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

function RotateRight(n)

         Angle = Angle + n

        -- while (Angle > 360) do

               if  Angle > 360  then  Angle = Angle - 360 end

         --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 = n - 360 end

    if n == 450 then n = 90 end

    return n

end

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

     --Angle = floor(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 "

      dx = dx* 10000  dx = floor(dx) dx = dx/10000

     dy = sin (Angle3) dy = dy* 10000  dy = floor(dy) dy = dy/10000

     x2 = x1 + dx * n

     y2 = y1 - dy * n

     x1=round(x1) y1=round(y1) x2=round(x2) y2=round(y2)

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

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

     return PenX

 end


 function test()         -- Use for debugging

      PenX = 0  PenY = 0

      Angle = 90

      color (25,22,255)            -- sets color to green

      backcolor (0,0,50)          -- sets background to blue

      clearscreen()

      redraw()

      pendown = 1

      --line(PenX,PenY,x2,y2)

      MoveSteps (100)  RotateRight(90)    MoveSteps (100)   RotateRight(90) MoveSteps (100)   RotateRight(90) MoveSteps (100)

      drawtext(50,40," angles")   drawtext(200,40,Angle)    drawtext(350,40,Angle2)    drawtext(550,40,Angle3)

      drawtext(50,60,"x1,y1,x2,y2")     drawtext(200,60,x1)    drawtext(350,60,y1)   drawtext(550,60,x2)    drawtext(750,60,y2)

      drawtext(50,80,"PenX,PenY,dx,dy")     drawtext(200,80,PenX)    drawtext(350,80,PenY)  drawtext(550,80,dx)    drawtext(750,80,dy)

      q=round(5.6)

      q=math.deg(math.pi)


      drawtext (50,100,q)

      redraw()

  end


 pendown = 0

color (250,220,0)            -- sets color to green

backcolor (0,0,50)          -- sets background to blue

clearscreen()

redraw()

complexity = 20

size = 99

cnt = 0


    while cnt < 100 do

clearscreen()

complexity = complexity + 2

PenX =0  PenY = 0

                  Angle = 90

pendown = 1





          cnt2 = 0

                 while cnt2 < complexity  do

          cnt3 = 0

     while cnt3 < 4 do

MoveSteps (complexity)

RotateRight(90)

cnt3 = cnt3 + 1

                        redraw()


end

RotateRight( 360/complexity )

ChangeColor(199)

cnt2 = cnt2+1

                end

                redraw()

         

pendown = 0


PenX =0  PenY = 0

Angle = 90

middle = size / 2

color (255,255,255)

    pendown = 1

          cnt2 = 0

                 while cnt2 < 180 do

          cnt3 = 0

while cnt3 < 4  do

MoveSteps (middle)

RotateRight(90)

cnt3 = cnt3 + 1


redraw()

end

RotateRight( 360/complexity )

cnt2 = cnt2 + 1

                end


pendown = 0

PenX =0  PenY = 0

Angle = 90

color (255,255,255)

    pendown = 1

cnt2 = 0

                 while cnt2 < 8   do

          cnt3 = 0

while cnt3 < 15  do

MoveSteps (3)

RotateRight( 24 )

cnt3 = cnt3+1

                        ChangeColor(128)

redraw()

end


RotateRight( 360/8 )

cnt2 = cnt2 + 1

                end


    pendown = 0

    PenX =  - 210

    PenY =  - 150

    redraw()

   cnt = cnt + 1

   wait (200)

   key = getkey()

   if (key > 31 ) then closewindow() end

   end



   

inkey()

closewindow()   


     







 

Make a free website with Yola