Skip to content

Instantly share code, notes, and snippets.

@tarvaina
Created August 9, 2013 08:56
Show Gist options
  • Select an option

  • Save tarvaina/6192187 to your computer and use it in GitHub Desktop.

Select an option

Save tarvaina/6192187 to your computer and use it in GitHub Desktop.
World goes round practice
{"description":"World goes round practice","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/oSnzjdo.png"}
var svg = d3.select("svg");
var rect = svg.append("rect").attr({
x: 0,
y: 0,
width: 800,
height: 800,
fill: "#ccc"
});
var world = tributary.world;
var projection = d3.geo.orthographic().clipAngle(90).translate([400, 400]);
var geopath = d3.geo.path().projection(projection);
var yawn = d3.scale.linear()
.domain([0, 800])
.range([-180, 180]);
var pitch = d3.scale.linear()
.domain([0, 800])
.range([90, -90]);
svg.selectAll('path').data(world.features).enter()
.append("path")
.attr({
d: geopath
});
rect.on("mousemove", function() {
var coords = d3.mouse(this);
console.log(coords);
projection.rotate([yawn(coords[0]), pitch(coords[1])]);
svg.selectAll('path').attr({ d: geopath });
});
Display the source blob
Display the rendered blob
Raw
Loading
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