[ Launch: Tributary inlet ] 6192187 by tarvaina
-
-
Save tarvaina/6192187 to your computer and use it in GitHub Desktop.
World goes round practice
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 characters
| {"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"} |
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 characters
| 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 }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment