Microsoft Small Basic

Program Listing: JTK247
' Cosmos
' Copyright (c) 2014 Nonki Takahashi. The MIT License.
'
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
colors = "1=HotPink;2=Pink;3=Gold;4=Tomato;5=White;"
nColors = Array.GetItemCount(colors)
GraphicsWindow.BackgroundColor = "Lime"
GraphicsWindow.Title = "Cosmos"
GraphicsWindow.PenWidth = 0
size = 50
For i = 1 To 100
x = Math.GetRandomNumber(gw)
y = Math.GetRandomNumber(gh)
GraphicsWindow.BrushColor = colors[Math.GetRandomNumber(nColors)]
AddCosmos()
EndFor
Sub AddCosmos
s = Math.GetRandomNumber(45) - 1
For a = s To 359 Step 45
_a = Math.GetRadians(a)
ox = x + (size * 5 / 16) * Math.Cos(_a)
oy = y + (size * 5 / 16) * Math.Sin(_a)
_w = size * 3 / 8
_h = size * 1.5 / 8
_x = ox - _w / 2
_y = oy - _h / 2
ell = Shapes.AddEllipse(_w, _h)
Shapes.Move(ell, _x, _y)
Shapes.Rotate(ell, a)
EndFor
GraphicsWindow.BrushColor = "Orange"
_x = x - size / 8
_y = y - size / 8
_w = size / 4
_h = size / 4
ell = Shapes.AddEllipse(_w, _h)
Shapes.Move(ell, _x, _y)
EndSub