Add built files

This commit is contained in:
Brandon Tilley 2013-12-21 00:57:25 -08:00
parent 8197a88cc3
commit ac1c54968d
5 changed files with 361 additions and 0 deletions

131
dist/planetaryjs-noplugins.js vendored Normal file
View File

@ -0,0 +1,131 @@
/*! Planetary.js v0.0.0
* Copyright (c) 2013 Brandon Tilley
*
* Released under the MIT license
* Date: 2013-12-21T08:56:23.017Z
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['d3', 'topojson'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('d3'), require('topojson'));
} else {
root.planetaryjs = factory(root.d3, root.topojson, root);
}
}(this, function(d3, topojson, window) {
'use strict';
var originalPlanetaryjs = null;
if (window) originalPlanetaryjs = window.planetaryjs;
var plugins = [];
var doDrawLoop = function(planet, canvas, hooks) {
d3.timer(function() {
planet.context.clearRect(0, 0, canvas.width, canvas.height)
for (var i = 0; i < hooks.onDraw.length; i++) {
hooks.onDraw[i]();
}
});
};
var startDraw = function(planet, canvas, localPlugins, hooks) {
for (var i = 0; i < plugins.length; i++) {
localPlugins.unshift(plugins[i]);
}
if (localPlugins.length == 0 && planetaryjs.plugins.earth) {
planet.loadPlugin(planetaryjs.plugins.earth());
}
for (var i = 0; i < localPlugins.length; i++) {
var plugin = localPlugins[i][0];
var config = localPlugins[i][1];
plugin(planet, config);
}
planet.canvas = canvas;
planet.context = canvas.getContext('2d');
if (hooks.onInit.length) {
var completed = 0;
var doNext = function(callback) {
var next = hooks.onInit[completed];
if (next.length) {
next(function() {
completed++;
callback();
});
} else {
next();
completed++;
setTimeout(callback, 0);
}
};
var check = function() {
if (completed >= hooks.onInit.length) doDrawLoop(planet, canvas, hooks);
else doNext(check);
}
doNext(check);
} else {
doDrawLoop(planet, canvas, hooks);
}
};
var planetaryjs = {
plugins: {},
noConflict: function() {
window.planetaryjs = originalPlanetaryjs;
return planetaryjs;
},
loadPlugin: function(plugin, defaultOptions) {
plugins.push([plugin, defaultOptions || {}]);
},
planet: function() {
var localPlugins = [];
var hooks = {
onInit: [],
onDraw: []
};
var planet = {
draw: function(canvas) {
startDraw(planet, canvas, localPlugins, hooks);
},
onInit: function(fn) {
hooks.onInit.push(fn);
},
onDraw: function(fn) {
hooks.onDraw.push(fn);
},
loadPlugin: function(plugin, defaultOptions) {
localPlugins.push([plugin, defaultOptions || {}]);
},
withSavedContext: function(fn) {
if (!this.context) {
throw new Error("No canvas to fetch context for")
}
this.context.save();
fn(this.context);
this.context.restore();
}
};
planet.projection = d3.geo.orthographic()
.clipAngle(90)
.precision(0);
planet.path = d3.geo.path().projection(planet.projection);
return planet;
}
};
return planetaryjs;
}));

2
dist/planetaryjs-noplugins.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
/*! 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});

225
dist/planetaryjs.js vendored Normal file
View File

@ -0,0 +1,225 @@
/*! Planetary.js v0.0.0
* Copyright (c) 2013 Brandon Tilley
*
* Released under the MIT license
* Date: 2013-12-21T08:56:22.909Z
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['d3', 'topojson'], factory);
} else if (typeof exports === 'object') {
module.exports = factory(require('d3'), require('topojson'));
} else {
root.planetaryjs = factory(root.d3, root.topojson, root);
}
}(this, function(d3, topojson, window) {
'use strict';
var originalPlanetaryjs = null;
if (window) originalPlanetaryjs = window.planetaryjs;
var plugins = [];
var doDrawLoop = function(planet, canvas, hooks) {
d3.timer(function() {
planet.context.clearRect(0, 0, canvas.width, canvas.height)
for (var i = 0; i < hooks.onDraw.length; i++) {
hooks.onDraw[i]();
}
});
};
var startDraw = function(planet, canvas, localPlugins, hooks) {
for (var i = 0; i < plugins.length; i++) {
localPlugins.unshift(plugins[i]);
}
if (localPlugins.length == 0 && planetaryjs.plugins.earth) {
planet.loadPlugin(planetaryjs.plugins.earth());
}
for (var i = 0; i < localPlugins.length; i++) {
var plugin = localPlugins[i][0];
var config = localPlugins[i][1];
plugin(planet, config);
}
planet.canvas = canvas;
planet.context = canvas.getContext('2d');
if (hooks.onInit.length) {
var completed = 0;
var doNext = function(callback) {
var next = hooks.onInit[completed];
if (next.length) {
next(function() {
completed++;
callback();
});
} else {
next();
completed++;
setTimeout(callback, 0);
}
};
var check = function() {
if (completed >= hooks.onInit.length) doDrawLoop(planet, canvas, hooks);
else doNext(check);
}
doNext(check);
} else {
doDrawLoop(planet, canvas, hooks);
}
};
var planetaryjs = {
plugins: {},
noConflict: function() {
window.planetaryjs = originalPlanetaryjs;
return planetaryjs;
},
loadPlugin: function(plugin, defaultOptions) {
plugins.push([plugin, defaultOptions || {}]);
},
planet: function() {
var localPlugins = [];
var hooks = {
onInit: [],
onDraw: []
};
var planet = {
draw: function(canvas) {
startDraw(planet, canvas, localPlugins, hooks);
},
onInit: function(fn) {
hooks.onInit.push(fn);
},
onDraw: function(fn) {
hooks.onDraw.push(fn);
},
loadPlugin: function(plugin, defaultOptions) {
localPlugins.push([plugin, defaultOptions || {}]);
},
withSavedContext: function(fn) {
if (!this.context) {
throw new Error("No canvas to fetch context for")
}
this.context.save();
fn(this.context);
this.context.restore();
}
};
planet.projection = d3.geo.orthographic()
.clipAngle(90)
.precision(0);
planet.path = d3.geo.path().projection(planet.projection);
return planet;
}
};
planetaryjs.plugins.topojson = function(planet, config) {
planet.onInit(function(done) {
if (config.world) {
planet.world = config.world;
setTimeout(done, 0);
} else {
var file = config.file || 'world-110m.json'
d3.json(file, function(err, world) {
if (err) {
throw new Error("Could not load JSON " + file);
}
planet.world = world;
done();
});
}
})
};
planetaryjs.plugins.oceans = function(planet, config) {
planet.onDraw(function() {
planet.withSavedContext(function(context) {
context.beginPath();
planet.path.context(context)({type: 'Sphere'});
context.fillStyle = config.fill || 'black';
context.fill();
if (config.stroke != false) {
context.strokeStyle = config.stroke;
context.stroke();
}
});
});
};
planetaryjs.plugins.land = function(planet, config) {
var land = null;
planet.onInit(function() {
land = topojson.feature(planet.world, planet.world.objects.land);
})
planet.onDraw(function() {
planet.withSavedContext(function(context) {
context.beginPath();
planet.path.context(context)(land);
if (config.fill != false) {
context.fillStyle = config.fill || 'white';
context.fill();
}
if (config.stroke) {
context.strokeStyle = config.stroke;
context.stroke();
}
});
});
};
planetaryjs.plugins.borders = function(planet, config) {
var borders = null;
planet.onInit(function() {
var countries = planet.world.objects.countries;
borders = topojson.mesh(planet.world, countries, function(a, b) {
return a.id !== b.id;
});
});
planet.onDraw(function() {
planet.withSavedContext(function(context) {
context.beginPath();
planet.path.context(context)(borders);
context.strokeStyle = config.stroke || 'gray';
context.stroke();
});
});
};
planetaryjs.plugins.earth = function(options) {
var options = options || {};
var topojsonOptions = options.topojson || {};
var oceanOptions = options.oceans || {};
var landOptions = options.land || {};
var bordersOptions = options.borders || {};
return function(planet, options) {
planetaryjs.plugins.topojson(planet, topojsonOptions);
planetaryjs.plugins.oceans(planet, oceanOptions);
planetaryjs.plugins.land(planet, landOptions);
planetaryjs.plugins.borders(planet, bordersOptions);
};
};
return planetaryjs;
}));

2
dist/planetaryjs.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
/*! 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]()})},l=function(n,t,o,e){for(var l=0;l<i.length;l++)o.unshift(i[l]);0==o.length&&u.plugins.earth&&n.loadPlugin(u.plugins.earth());for(var l=0;l<o.length;l++){var a=o[l][0],s=o[l][1];a(n,s)}if(n.canvas=t,n.context=t.getContext("2d"),e.onInit.length){var c=0,f=function(n){var t=e.onInit[c];t.length?t(function(){c++,n()}):(t(),c++,setTimeout(n,0))},h=function(){c>=e.onInit.length?r(n,t,e):f(h)};f(h)}else r(n,t,e)},u={plugins:{},noConflict:function(){return o.planetaryjs=e,u},loadPlugin:function(n,t){i.push([n,t||{}])},planet:function(){var t=[],o={onInit:[],onDraw:[]},e={draw:function(n){l(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 u.plugins.topojson=function(t,o){t.onInit(function(e){if(o.world)t.world=o.world,setTimeout(e,0);else{var i=o.file||"world-110m.json";n.json(i,function(n,o){if(n)throw new Error("Could not load JSON "+i);t.world=o,e()})}})},u.plugins.oceans=function(n,t){n.onDraw(function(){n.withSavedContext(function(o){o.beginPath(),n.path.context(o)({type:"Sphere"}),o.fillStyle=t.fill||"black",o.fill(),0!=t.stroke&&(o.strokeStyle=t.stroke,o.stroke())})})},u.plugins.land=function(n,o){var e=null;n.onInit(function(){e=t.feature(n.world,n.world.objects.land)}),n.onDraw(function(){n.withSavedContext(function(t){t.beginPath(),n.path.context(t)(e),0!=o.fill&&(t.fillStyle=o.fill||"white",t.fill()),o.stroke&&(t.strokeStyle=o.stroke,t.stroke())})})},u.plugins.borders=function(n,o){var e=null;n.onInit(function(){var o=n.world.objects.countries;e=t.mesh(n.world,o,function(n,t){return n.id!==t.id})}),n.onDraw(function(){n.withSavedContext(function(t){t.beginPath(),n.path.context(t)(e),t.strokeStyle=o.stroke||"gray",t.stroke()})})},u.plugins.earth=function(n){var n=n||{},t=n.topojson||{},o=n.oceans||{},e=n.land||{},i=n.borders||{};return function(n){u.plugins.topojson(n,t),u.plugins.oceans(n,o),u.plugins.land(n,e),u.plugins.borders(n,i)}},u});

1
dist/world-110m.json vendored Normal file

File diff suppressed because one or more lines are too long