Microsoft Small Basic

Program Listing: WNV073
' SmallBasic Version 1.2
' Program: ColorSpiral
' Changelog:
' Author: Pappa Lapub
' Website: https://social.msdn.microsoft.com/Forums/en-US/f7b62609-6994-48e1-b353-8de4b278ec16/challenge-of-the-month-june-2016
' ImportURL: http://smallbasic.com/program/?
' Extension:
' Comment: Draw a multi-coloured spiral
'
' Variables:
' ToDo:
' ================================================================================
gw = 670
cent = gw/2
a = 40
pi = 3.14159
dRad = pi/36
arrCols = "1=DarkViolet;2=DarkBlue;3=LightBlue;4=Green;5=Yellow;6=Orange;7=Red;"
nCols = Array.GetItemCount(arrCols)
dRot = 2*pi / nCols

GraphicsWindow.Width = gw
GraphicsWindow.Height = gw
GraphicsWindow.Top = 0
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.PenWidth = a * 2*pi / nCols

For n = 0 To nCols-1
GraphicsWindow.PenColor = arrCols[n+1]
x0 = cent
y0 = cent
For rad = dRad To 4*pi Step dRad
r = a * rad '' Archimedische Spirale
x = cent - r * Math.Cos(rad + n*dRot)
y = cent + r * Math.Sin(rad + n*dRot)
GraphicsWindow.DrawLine(x0,y0, x,y)
x0 = x
y0 = y
EndFor
EndFor