Microsoft Small Basic

Program Listing: WBN030
' Turtle Spiral
' Copyright © 2018 Nonki Takahashi. The MIT License.

Turtle.Speed = 10
GraphicsWindow.PenWidth = 4
a = 6
d = 4
Turtle.PenUp()
For i = 1 To 100
r = i * d
c = 2 * Math.Pi * r / (360 / a)
Turtle.Move(c)
Turtle.Turn(a)
Turtle.PenDown()
For j = 1 To 360 / a
r = 255 * Math.Floor((Math.Remainder(j, 6) + 1) / 4)
g = 255 * Math.Remainder(Math.Floor((Math.Remainder(j, 6) + 1) / 2), 2)
b = 255 * Math.Remainder(Math.Remainder(j, 6) + 1, 2)
GraphicsWindow.PenColor = GraphicsWindow.GetColorFromRGB(r, g, b)
Turtle.Move(c)
Turtle.Turn(a)
EndFor
Turtle.PenUp()
Turtle.Turn(-90)
Turtle.Move(d)
Turtle.Turn(90)
EndFor
GraphicsWindow.Title = "Turtle Spiral"