Create a gist now

Instantly share code, notes, and snippets.

Spinny Globe
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
circle,
path {
fill: none;
stroke: #000;
}
circle {
stroke-width: 2px;
}
</style>
<body>
<script src="http://d3js.org/d3.v2.min.js"></script>
<script src="https://raw.github.com/d3/d3-plugins/clip/geo/clip/clip.js"></script>
<script>
var width = 960,
height = 500,
radius = 240;
var origin = [-71, 42],
velocity = [.010, -.002],
t0 = Date.now();
var projection = d3.geo.azimuthal()
.mode("orthographic")
.scale(radius)
.translate([width / 2, height / 2]);
var clip = d3.geo.clip();
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("readme.json", function(err, geometry) {
var feature = svg.append("path")
.datum(geometry)
.attr("d", draw);
d3.timer(function() {
var t = Date.now() - t0,
o = [origin[0] + velocity[0] * t, origin[1] + velocity[1] * t];
projection.origin(o);
clip.origin(o);
feature.attr("d", draw);
});
function draw(d) {
return path(clip(d));
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment