Recursive Circles

to generate a new and unique variation

Source Code

Every variart piece is open source, you can see exactly how it is drawn from the code.

// Adapted from Daniel Shiffman's `The Nature of Code`, Example 8.1

function drawCircle(x, y, radius){
  s.circle(x, y, radius)
   .attr({fill: 'none', stroke: 'black', strokeWidth: 1});
  
  // Prevent an infinte loop by stopping before we get too small
  if (radius > 2){
    // Call itself twice, for every circle a smaller circle is drawn to the left and right
    drawCircle(x + radius/2, y, radius/2);
    drawCircle(x - radius/2, y, radius/2);
  }
}

drawCircle(width/2, height/2, getRandomInt(100, 500));