Microsoft Small Basic

Program Listing:
Embed this in your website
' Variable to define for the drawing function

' startX : X origin of the spiral
' startY : Y origin of the spiral
' radius : Distance origin-outer spire
' lines :Number of line that make the spiral
' spires :Number of spires
' rotation : Rotation of the spiral in 0° - 360°
'
Sub Spiral
  Turtle.PenUp()
  Turtle.MoveTo(startX,startY)
  Turtle.PenDown()
  GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()
  rotation = Math.GetRadians(rotation)
  i=1
  While(i<=lines)
    if(type="log")Then
      m=Math.Power(radius,i/lines)
    Else
      m=(i / lines) * radius
    EndIf
    x = startX + Math.Cos(i * spires / lines * 2 * Math.Pi+rotation) * m
    y = startY + Math.Sin(i*  spires / lines * 2 * Math.Pi+rotation) * m
    Turtle.MoveTo(x,y)
    i=i+1
  EndWhile
EndSub



'Example
startX=Turtle.x
startY=Turtle.y
Turtle.speed=10

GraphicsWindow.BrushColor="Black"
GraphicsWindow.FillEllipse(startX+200,startY,3,3)
GraphicsWindow.FillEllipse(startX,startY+200,3,3)
GraphicsWindow.FillEllipse(startX,startY-200,3,3)
GraphicsWindow.FillEllipse(startX-200,startY,3,3)

radius=200
lines=500
spires=6
rotation=0
type="std"
GraphicsWindow.DrawBoundText(0,0,200,"Archimede's spiral")
For j=0 To 270 Step 90
  rotation=j
  Spiral()
EndFor

Program.Delay(500)
GraphicsWindow.Clear()

type="log"
GraphicsWindow.DrawBoundText(0,0,200,"Logarithmic spiral")
For j=0 To 270 Step 90
  rotation=j
  Spiral()
EndFor
Copyright (c) Microsoft Corporation. All rights reserved.