Rev | Line | |
---|
[76] | 1 | <!DOCTYPE html> |
---|
| 2 | <html> |
---|
| 3 | <head> |
---|
| 4 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
---|
| 5 | <title>Delaunay Triangulation</title> |
---|
| 6 | <script type="text/javascript" src="../../d3.js"></script> |
---|
| 7 | <script type="text/javascript" src="../../d3.geom.js"></script> |
---|
| 8 | <style type="text/css"> |
---|
| 9 | |
---|
| 10 | @import url("../../lib/colorbrewer/colorbrewer.css"); |
---|
| 11 | |
---|
| 12 | path { |
---|
| 13 | stroke: #000; |
---|
| 14 | stroke-width: .5px; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | </style> |
---|
| 18 | </head> |
---|
| 19 | <body> |
---|
| 20 | <script type="text/javascript"> |
---|
| 21 | |
---|
| 22 | var w = 960, |
---|
| 23 | h = 500; |
---|
| 24 | |
---|
| 25 | var vertices = d3.range(500).map(function(d) { |
---|
| 26 | return [Math.random() * w, Math.random() * h]; |
---|
| 27 | }); |
---|
| 28 | |
---|
| 29 | var svg = d3.select("body") |
---|
| 30 | .append("svg:svg") |
---|
| 31 | .attr("width", w) |
---|
| 32 | .attr("height", h) |
---|
| 33 | .attr("class", "PiYG"); |
---|
| 34 | |
---|
| 35 | svg.append("svg:g") |
---|
| 36 | .selectAll("path") |
---|
| 37 | .data(d3.geom.delaunay(vertices)) |
---|
| 38 | .enter().append("svg:path") |
---|
| 39 | .attr("class", function(d, i) { return "q" + (i % 9) + "-9"; }) |
---|
| 40 | .attr("d", function(d) { return "M" + d.join("L") + "Z"; }); |
---|
| 41 | |
---|
| 42 | </script> |
---|
| 43 | </body> |
---|
| 44 | </html> |
---|
Note: See
TracBrowser
for help on using the repository browser.