Created
October 26, 2015 05:34
-
-
Save anonymous/b902f3a61e9b2663bad6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<-$ | |
svg = d3.select '#map' .append 'svg:svg' | |
.attr 'width' '1440' | |
.attr 'height' '700' | |
g = svg.append 'g' | |
voronoi_map = g.append 'svg:g' | |
.attr 'id' 'voronoi' | |
circle = [[400 + 100 * Math.cos(i * 3.14 / 180), 300 + 100 * Math.sin(i * 3.14 / 180)] for i to 360] | |
circle = d3.geom.polygon circle | |
data = [[450, 350], [410, 360], [470, 310], [420, 320]] | |
voronoi = d3.geom.voronoi! | |
voronoi_map.selectAll "path" .data(voronoi data, (d) -> "M#{d.join 'L'}Z" .map (v) -> circle.clip d3.geom.polygon v) | |
.enter!append 'path' | |
.attr 'd' (d) -> "M#{d.join 'L'}Z" | |
.attr 'fill' 'none' | |
.attr 'stroke' 'black' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment