Sha256: cd75336dc1b648be3d4b606d54fd7b7293e85dbc35ed023d4f67ae97a1a09490

Contents?: true

Size: 1.42 KB

Versions: 25

Compression:

Stored size: 1.42 KB

Contents

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Convex Hull</title>
    <script type="text/javascript" src="../../d3.js"></script>
    <script type="text/javascript" src="../../d3.geom.js"></script>
    <style type="text/css">

svg {
  border: solid 1px #aaa;
  background: #eee;
}

path {
  fill: lightsteelblue;
  stroke: #000;
}

circle {
  fill: #fff;
  stroke: #000;
}

    </style>
  </head>
  <body>
    <script type="text/javascript">

var w = 960,
    h = 500;

var vertices = d3.range(15).map(function(d) {
  return [
    w / 4 + Math.random() * w / 2,
    h / 4 + Math.random() * h / 2
  ];
});

var svg = d3.select("body")
  .append("svg")
    .attr("width", w)
    .attr("height", h)
    .attr("pointer-events", "all")
    .on("mousemove", move)
    .on("click", click);

update();

function update() {
  svg.selectAll("path")
      .data([d3.geom.hull(vertices)])
      .attr("d", function(d) { return "M" + d.join("L") + "Z"; })
	  .enter().append("path")
	    .attr("d", function(d) { return "M" + d.join("L") + "Z"; });

  svg.selectAll("circle")
      .data(vertices.slice(1))
    .enter().append("circle")
      .attr("transform", function(d) { return "translate(" + d + ")"; })
      .attr("r", 3);
}

function move() {
  vertices[0] = d3.svg.mouse(this);
  update();
}

function click() {
  vertices.push(d3.svg.mouse(this));
  update();
}
    </script>
  </body>
</html>

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
picky-statistics-4.5.0 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.4.2 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.4.1 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.4.0 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.3.2 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.3.1 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.3.0 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.2.4 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.2.3 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.2.2 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.2.1 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.2.0 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.1.0 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.9 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.8 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.7 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.6 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.5 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.4 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html
picky-statistics-4.0.3 lib/picky-statistics/application/javascripts/d3/examples/hull/hull.html