planetary.js/dist/planetaryjs-noplugins.min.js
2013-12-21 00:57:25 -08:00

2 lines
1.4 KiB
JavaScript

/*! Planetary.js 0.0.0 | (c) 2013 Brandon Tilley | Released under MIT License */
!function(n,t){"function"==typeof define&&define.amd?define(["d3","topojson"],t):"object"==typeof exports?module.exports=t(require("d3"),require("topojson")):n.planetaryjs=t(n.d3,n.topojson,n)}(this,function(n,t,o){"use strict";var e=null;o&&(e=o.planetaryjs);var i=[],r=function(t,o,e){n.timer(function(){t.context.clearRect(0,0,o.width,o.height);for(var n=0;n<e.onDraw.length;n++)e.onDraw[n]()})},a=function(n,t,o,e){for(var a=0;a<i.length;a++)o.unshift(i[a]);0==o.length&&c.plugins.earth&&n.loadPlugin(c.plugins.earth());for(var a=0;a<o.length;a++){var u=o[a][0],f=o[a][1];u(n,f)}if(n.canvas=t,n.context=t.getContext("2d"),e.onInit.length){var s=0,h=function(n){var t=e.onInit[s];t.length?t(function(){s++,n()}):(t(),s++,setTimeout(n,0))},l=function(){s>=e.onInit.length?r(n,t,e):h(l)};h(l)}else r(n,t,e)},c={plugins:{},noConflict:function(){return o.planetaryjs=e,c},loadPlugin:function(n,t){i.push([n,t||{}])},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={draw:function(n){a(e,n,t,o)},onInit:function(n){o.onInit.push(n)},onDraw:function(n){o.onDraw.push(n)},loadPlugin:function(n,o){t.push([n,o||{}])},withSavedContext:function(n){if(!this.context)throw new Error("No canvas to fetch context for");this.context.save(),n(this.context),this.context.restore()}};return e.projection=n.geo.orthographic().clipAngle(90).precision(0),e.path=n.geo.path().projection(e.projection),e}};return c});