block by aaizemberg d9f509d05ab6ac9c18c1

graphical perception (areas)

Full Screen

index.html

<!DOCTYPE HTML>
<html>
<head>
  <script src="//d3js.org/d3.v3.min.js"></script>
</head>
<body>
  <canvas id="myCanvas" width="600" height="300" style="border:1px solid #bbb;"></canvas>
  <script>
    var canvas = document.getElementById("myCanvas");    
    var ctx = canvas.getContext("2d");
    var centerX = canvas.width / 2;
    var centerY = canvas.height / 2;

    var r = d3.scale.sqrt().domain([0, 100]).range([0, 100]);  
    var px = d3.scale.linear().domain([0, 1]).range([0, canvas.width]);  

    ctx.fillStyle = "#aaa";
    //ctx.strokeStyle = "#aaa";

    ctx.beginPath();
    ctx.arc(px(1/4), centerY, r(50), 0, 2 * Math.PI);
    ctx.fill();
    //ctx.stroke();

    ctx.beginPath();
    ctx.arc(px(3/4), centerY, r(100), 0, 2 * Math.PI);
    ctx.fill();
    //ctx.stroke();
      
  </script>
</body>
</html>