Skip to content

Instantly share code, notes, and snippets.

@blech
Forked from mbostock/.block
Last active December 19, 2015 22:18
Show Gist options
  • Save blech/6025967 to your computer and use it in GitHub Desktop.
Save blech/6025967 to your computer and use it in GitHub Desktop.
BBC One

Just your BBC spinny globe, circa 1985. (TODO: add reversed antipodes as bg layer.)

<!DOCTYPE html>
<meta charset="utf-8">
<title>BBC One Globe. husk.org.</title>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 500,
velocity = .01,
then = Date.now();
var projection = d3.geo.orthographic()
.scale(250)
.translate([width / 2, height / 2])
.clipAngle(90);
var canvas = d3.select("body").append("canvas")
.attr("width", width)
.attr("height", height);
var c = canvas.node().getContext('2d');
var path = d3.geo.path()
.projection(projection)
.context(c);
d3.json("/d/5879060/world-110m.json", function(error, world) {
var land = topojson.feature(world, world.objects.land),
globe = {type: "Sphere"};
d3.timer(function() {
var angle = velocity * (Date.now() - then);
var rotate = [0, 0, 0];
rotate[0] = angle, projection.rotate(rotate);
c.clearRect(0, 0, width, height);
c.fillStyle = 'rgba(0,0,102,1)',
c.beginPath(),
path(globe),
c.fill(),
c.stroke();
c.fillStyle = 'rgba(0,204,0,.75)',
c.beginPath(),
path(land),
c.fill();
});
});
</script>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment