Procedurally generated galaxy (image-heavy)

Miscellaneous Forums/Blitz Showcase/Procedurally generated galaxy (image-heavy)

Let there be light. You can build your own galaxy with this code, here is my simple version:

Graphics 800,600,32,2

arms=4
stars=100000
radius=25
spread#=70
rotation=1.6

plotgalaxy(stars,arms,radius,spread,wi#,rotation)
Color 255,255,255

While Not KeyDown(1)
Wend

End

Function plotgalaxy(stars,arms,radius,spread#,wi#,rotation)
   Repeat
      px=px+plotarm(stars,arms,radius,spread#,wi#,rotation)
      wi#=wi#+(360/arms)
   Until wi#=>360
   Return px
End Function

Function plotarm(stars,arms,radius,spread#,angle,rotation)
   For i=1 To (stars/arms)
      fR#=Rnd(0,radius)^1.5+Rnd(-spread#,spread#)
      fQ#=Rnd(0,spread)
      If Rnd(0,1)>.5 Then fQ#=-fQ#
      fK#=rotation
      fX#=fR#*Cos(angle+fR#*fK#+fQ#)
      fY#=fR#*Sin(angle+fR#*fK#+fQ#)
      col#=255
      Color col#,col#,col#
      Plot(400+fX#,300+fY#)
      px=px+1
   Next
   Return px
End Function