-
-
Save jasondavies/3766821 to your computer and use it in GitHub Desktop.
Revisions
-
jasondavies revised this gist
Oct 26, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ <style> body { padding: 0px 230px; background: #000; } </style> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500" style="width: 1080px; height: 1000px"></canvas> <script> -
jasondavies revised this gist
Oct 12, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ <style> body { padding: 0px 230px; background: #000; } </style> <script src="https://raw.github.com/jasondavies/d3/projection/d3.min.js"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500" style="width: 1080px; height: 1000px"></canvas> <script> -
jasondavies revised this gist
Sep 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <!DOCTYPE html> <meta charset="utf-8"> <style> body { padding: 0px 230px; background: #000; } </style> <script src="https://raw.github.com/jasondavies/d3/projection/d3.v2.min.js"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> -
jasondavies revised this gist
Sep 28, 2012 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,30 +1,30 @@ <!DOCTYPE html> <meta charset="utf-8"> <style> body { padding: 0px 230px; } </style> <script src="https://raw.github.com/jasondavies/d3/projection/d3.v2.min.js"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500" style="width: 1080px; height: 1000px"></canvas> <script> var width = 500 / 2, height = 500 / 2; var projection = d3.geo.stereographic() .scale(50) .translate([width / 2, height / 2]); var path = d3.geo.path() .projection(projection); var x = d3.scale.linear() .domain([180, -180]) .range([0, width * 2]); var y = d3.scale.linear() .domain([90, -90]) .range([height * 2, 0]); var image = new Image; image.onload = onload; -
jasondavies revised this gist
Sep 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ <style> body { padding: 150px 380px; } </style> <script src="https://raw.github.com/jasondavies/d3/projection/d3.v2.min.js"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500"></canvas> <script> -
jasondavies revised this gist
Sep 23, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,8 @@ image.src = "readme-world.jpeg"; function onload() { var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"), sourceWidth = image.width, sourceHeight = image.height; context.drawImage(image, 0, 0, sourceWidth, sourceHeight); @@ -45,8 +46,8 @@ context.clearRect(0, 0, sourceWidth, sourceHeight); refresh(); d3.select(window).on("mousemove", function() { var p = d3.mouse(canvas); projection.rotate([x.invert(p[0]), y.invert(p[1])]); refresh(); }); -
jasondavies revised this gist
Sep 23, 2012 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,15 @@ <!DOCTYPE html> <meta charset="utf-8"> <style> body { padding: 150px 380px; } </style> <script src="http://d3js.org/d3.v2.min.js?2.10.1"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500"></canvas> <script> var width = 200, height = 200; var projection = d3.geo.stereographic() .scale(75) @@ -43,11 +45,9 @@ context.clearRect(0, 0, sourceWidth, sourceHeight); refresh(); d3.select("#canvas").on("mousemove", function() { var p = d3.mouse(this); projection.rotate([x.invert(p[0]), y.invert(p[1])]); refresh(); }); -
jasondavies revised this gist
Sep 23, 2012 . 1 changed file with 12 additions and 16 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,16 @@ <!DOCTYPE html> <meta charset="utf-8"> <script src="http://d3js.org/d3.v2.min.js?2.10.1"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="540" height="500"></canvas> <script> var width = 200, height = 200, rotate = [0, 0, 0]; var projection = d3.geo.stereographic() .scale(75) .translate([width / 2, height / 2]); var path = d3.geo.path() @@ -44,14 +38,16 @@ out = context.createImageData(width, height), data = out.data, interpolate = bilinear(function(x, y, offset) { return source[(y * sourceWidth + x) * 4 + offset]; }); context.clearRect(0, 0, sourceWidth, sourceHeight); refresh(); d3.timer(function(elapsed) { rotate[0]++; rotate[1]++; rotate[2]++; projection.rotate(rotate); refresh(); }); -
jasondavies revised this gist
Sep 22, 2012 . 3 changed files with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ A modified version of Mike Bostock’s mesmerising [stereographic projection example](http://bl.ocks.org/3763057). A NASA [Blue Marble](http://visibleearth.nasa.gov/view.php?id=73776) raster image is reprojected using `d3.geo.stereographic().invert` from the [geo.projection D3 plugin](https://github.com/d3/d3-plugins/tree/master/geo/projection). 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 charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ var image = new Image; image.onload = onload; image.src = "readme-world.jpeg"; function onload() { var context = document.getElementById("canvas").getContext("2d"), File renamed without changes -
jasondavies revised this gist
Sep 22, 2012 . 3 changed files with 60 additions and 36 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ A modified version of Mike Bostock’s [mesmerising stereographic projection example](http://bl.ocks.org/3763057). A NASA [Blue Marble](http://visibleearth.nasa.gov/view.php?id=73776) raster image is reprojected using `d3.geo.stereographic().invert` from the [geo.projection D3 plugin](https://github.com/d3/d3-plugins/tree/master/geo/projection). 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 charactersOriginal file line number Diff line number Diff line change @@ -2,27 +2,22 @@ <meta charset="utf-8"> <style> body { padding: 100px 280px; } </style> <script src="http://d3js.org/d3.v2.min.js?2.10.1"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <canvas id="canvas" width="960" height="500"></canvas> <script> var width = 400, height = 300; var projection = d3.geo.stereographic() .scale(100) .translate([width / 2, height / 2]); var path = d3.geo.path() .projection(projection); @@ -35,32 +30,60 @@ .domain([90, -90]) .range([height, 0]); var image = new Image; image.onload = onload; image.src = "world.jpeg"; function onload() { var context = document.getElementById("canvas").getContext("2d"), sourceWidth = image.width, sourceHeight = image.height; context.drawImage(image, 0, 0, sourceWidth, sourceHeight); var source = context.getImageData(0, 0, sourceWidth, sourceHeight).data, out = context.createImageData(width, height), data = out.data, interpolate = bilinear(function(x, y, offset) { return source[(y * 540 + x) * 4 + offset]; }); context.clearRect(0, 0, 540, 270); refresh(); d3.select("#canvas").on("mousemove", function() { var p = d3.mouse(this); projection.origin([x.invert(p[0]), y.invert(p[1])]); refresh(); }); function refresh() { for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { var i = (y * width + x) * 4, location = projection.invert([x, y]), sx = (180 + location[0]) / 360 * sourceWidth, sy = (90 - location[1]) / 180 * sourceHeight; data[i++] = interpolate(sx, sy, 0); data[i++] = interpolate(sx, sy, 1); data[i++] = interpolate(sx, sy, 2); data[i++] = 0xff; } } context.putImageData(out, 0, 0); } } function bilinear(f) { return function(x, y, o) { var x0 = Math.floor(x), y0 = Math.floor(y), x1 = Math.ceil(x), y1 = Math.ceil(y); if (x0 === x1 || y0 === y1) return f(x0, y0, o); return (f(x0, y0, o) * (x1 - x) * (y1 - y) + f(x1, y0, o) * (x - x0) * (y1 - y) + f(x0, y1, o) * (x1 - x) * (y - y0) + f(x1, y1, o) * (x - x0) * (y - y0)) / ((x1 - x0) * (y1 - y0)); }; } </script> LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
mbostock revised this gist
Sep 21, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,11 +28,11 @@ .projection(projection); var x = d3.scale.linear() .domain([180, -180]) .range([0, width]); var y = d3.scale.linear() .domain([90, -90]) .range([height, 0]); var svg = d3.select("body").append("svg") @@ -41,7 +41,7 @@ svg.on("mousemove", function() { var p = d3.mouse(this); projection.origin([x.invert(p[0]), y.invert(p[1])]); svg.selectAll("path").attr("d", path); }); -
mbostock created this gist
Sep 21, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,66 @@ <!DOCTYPE html> <meta charset="utf-8"> <style> .land { fill: none; stroke: #000; } .boundary { fill: none; stroke: #aaa; } </style> <body> <script src="http://d3js.org/d3.v2.min.js?2.10.1"></script> <script src="https://raw.github.com/d3/d3-plugins/master/geo/projection/projection.js"></script> <script> var width = 960, height = 500; var projection = d3.geo.stereographic() .scale(300); var path = d3.geo.path() .projection(projection); var x = d3.scale.linear() .domain([-180, 180]) .range([0, width]); var y = d3.scale.linear() .domain([-90, 90]) .range([height, 0]); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); svg.on("mousemove", function() { var p = d3.mouse(this); projection.rotate([x.invert(p[0]), y.invert(p[1])]); svg.selectAll("path").attr("d", path); }); d3.json("/d/3682676/readme-boundaries.json", function(collection) { svg.append("g") .attr("class", "boundary") .selectAll("path") .data(collection.geometries) .enter().append("path") .attr("d", path); }); d3.json("/d/3682676/readme-land.json", function(collection) { svg.insert("g", ".boundary") .attr("class", "land") .selectAll("path") .data(collection.geometries) .enter().append("path") .attr("d", path); }); </script>