block by aaizemberg 9910af452cad53ece115cd82c03d03f2

Dibujando 30.000 círculos con <canvas>

Full Screen

index.html

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>30.000 círculos</title>
</head>
<body>

  <canvas id="myCanvas" width="960" height="500" style="border:1px solid #000;"></canvas>

<script>
  function rc() {
  return (Math.random() * 256);
}

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");

for (i = 0; i < 30000; i++) { 
  ctx.beginPath();
  ctx.arc(c.width * Math.random(), 
          c.height * Math.random(), 
          10 * Math.random(), 
          0, 
          2 * Math.PI);
  ctx.fillStyle = 'rgba('+rc()+', '+rc()+', '+rc()+', 0.5)';
  ctx.fill();
}
</script>  
  
</body>
</html>