[ Launch: simple voronoi ] 10739790 by danharr
[ Launch: simple voronoi ] 5493432 by enjalot
-
-
Save danharr/10739790 to your computer and use it in GitHub Desktop.
simple voronoi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"simple voronoi","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"points.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/dR1mfxr.png","ajax-caching":true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vertices = tributary.points.map(function(d) { | |
return [d.x, d.y] | |
}); | |
var svg = d3.select("svg"); | |
var xScale = d3.scale.linear().domain([0,200]).range([10,600]); | |
var mydata = [ | |
[100,200], | |
[200,400], | |
[50,25], | |
[400,680], | |
[200,200] | |
]; | |
svg.selectAll("circle") | |
.data(mydata) | |
.enter() | |
.append("circle") | |
.attr({ | |
cx: function(d) { return xScale(d[0]) }, | |
cy: function(d) { return d[1] }, | |
r: 5 | |
}) | |
var voronoi = d3.geom.voronoi(mydata) | |
var pathFn = function(d) { | |
return "M" + d.join("L") + "Z"; | |
} | |
svg.selectAll("path") | |
.data(voronoi) | |
.enter() | |
.append("path") | |
.attr("d", pathFn) | |
.classed("voronoi", true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"x": 100, "y": 100}, | |
{"x": 150, "y": 120}, | |
{"x": 200, "y": 130}, | |
{"x": 100, "y": 400}, | |
{"x": 100, "y": 500}, | |
{"x": 140, "y": 400}, | |
{"x": 550, "y": 400}, | |
{"x": 450, "y": 350}, | |
{"x": 238, "y": 309}, | |
{"x": 321, "y": 500}, | |
{"x": 140, "y": 223}, | |
{"x": 322, "y": 213}, | |
{"x": 648, "y": 350}, | |
{"x": 587, "y": 120} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.voronoi { | |
fill: #8AEEEE; | |
stroke: #000000; | |
fill-opacity: 0.5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment