Published
Edited
Apr 5, 2019
1 fork
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
function drawCircle(_x, _y, _radius, _fact, sketch) {
sketch.ellipse(_x, _y, _radius/2, _radius/2);

// Notice our condition to avoid an infinite loop!
// Try different values, comment out lines, try to understand
// the general construction
if (_radius > 7.3) {
_radius *= _fact;
drawCircle(_x+_radius/2, _y, _radius/2, 0.89, sketch);
drawCircle(_x-_radius/2, _y, _radius/2, 0.89, sketch);
drawCircle(_x, _y+_radius/2, _radius/2, 0.89, sketch);
drawCircle(_x, _y-_radius/2, _radius/2, 0.89, sketch);
}
}
Insert cell
Insert cell
p5(sketch => {
  sketch.setup = function() {
sketch.createCanvas(640, 420);
   sketch.background(255);
sketch.noFill();
};
sketch.draw = function() {
sketch.background(0,0,33);
sketch.stroke(255);
sketch.strokeWeight(1);

// we call our function here passing in values for our arguments
// Try different values for the radius & factorial arguments
drawCircle(320, 210, 750, 0.65, sketch);
 };
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more