title: Algorithm to generate a starfield
body: <p>I just learned about Logo yesterday. Being born in the nineties I never came across it before. So I started using an online <a href="http://www.calormen.com/logo/" rel="nofollow noreferrer">Logo Interpreter</a> written by Joshua Bell and I decided to write a <code>circle</code> function to make concentric circles. This is what I wrote:</p>
  
  <pre><code>cs
  
  to circle
  penup forward :radius right 90
  pendown repeat 360 [forward 3.14 * :radius / 180 right 1]
  penup left 90 back :radius pendown
  end
  
  make "radius 30
  
  repeat 160 [circle make "radius :radius + 30]
  </code></pre>
  
  <p>Interestingly the drawing canvas is a toroidal array. Hence the circles end up overlapping. By drawing 160 concentric circles with increasing radii in multiples of 30 I ended up getting an image like this:</p>
  
  <p><img src="https://i.stack.imgur.com/TTRFu.png" alt="Logo starfield generated by 160 concentric circles with increasing radii in multiples of 30."></p>
  
  <p>This is truly astonishing. At first glance it looks like a genuine picture of the night sky, and it got me thinking - is there a general algorithm to draw a starfield?</p>
  
  <p>BTW if you look closely you can see a grid of <code>30 x 30</code> pixel squares. The boundaries are black so it's a little hard to notice.</p>