for(let c =0; c < cMax; c +=1){ let newCircle; let hit =true; while(hit){ hit =false; newCircle ={ x: Math.random()* sketchWidth, y: Math.random()* sketchHeight }; for(let cc =0; cc < circles.length; cc +=1){ if(hitTest(newCircle, circles[cc])){ hit =true; } } }
circles.push(newCircle); }
console.log(circles.length);
functionhitTest(circle1, circle2){ let x1Min = circle1.x - circleRadius /2; let x1Max = circle1.x + circleRadius /2; let y1Min = circle1.y - circleRadius /2; let y1Max = circle1.y + circleRadius /2;
let x2Min = circle2.x - circleRadius /2; let x2Max = circle2.x + circleRadius /2; let y2Min = circle2.y - circleRadius /2; let y2Max = circle2.y + circleRadius /2;