Example 4: Circle of Circles

refresh(dc, width, height) // Sample code by Jim Bumgardner
{
  dc.clearRect(0,0,width,height);
  
  dc.fillStyle='#000';
  var nbr_circles = 24;
  
  var lg_rad = (width/2) * .85;
  var lg_circ = 2*Math.PI*lg_rad;
  var sm_rad = (lg_circ / nbr_circles) / 2;
  var cx = width/2;
  var cy = height/2;
  
  for (var i = 1; i <= nbr_circles; ++i) {
    dc.beginPath();
    var angle = i*2*Math.PI/nbr_circles;
    var x = cx + Math.cos(angle) * lg_rad;
    var y = cy + Math.sin(angle) * lg_rad;
    dc.arc(x, y, sm_rad, 0, 2*Math.PI, false);
    dc.fill();
  }
  
}