Skip to content

Instantly share code, notes, and snippets.

@vicapow
Forked from mbostock/.block
Last active August 29, 2015 13:56
Show Gist options
  • Save vicapow/9338346 to your computer and use it in GitHub Desktop.
Save vicapow/9338346 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="../../d3.js"></script>
<script src="../../topojson.js"></script>
<style>
body{
margin: 0;
}
</style>
<script>
// originally from: http://bl.ocks.org/mbostock/3734273
// width = window.innerWidth, height = window.innerHeight
var width = 1050, height = 1500
var velocity = .01,
t0 = Date.now();
var projection = d3.geo.equirectangular()
.translate([width/2, height/2])
.scale(500)
var canvas = d3.select("body").append("canvas")
.attr("width", width)
.attr("height", height);
var context = canvas.node().getContext("2d");
var path = d3.geo.path()
.projection(projection)
.context(context);
d3.json("/d/4090846/world-110m.json", function(error, world) {
var land = topojson.feature(world, world.objects.land);
window.step = function() {
var t = Date.now() - t0;
projection.rotate([0, velocity * t]);
context.clearRect(0, 0, width, height);
context.beginPath();
path(land);
context.fill();
}
window.is_ready = true
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment