Update site

This commit is contained in:
Brandon Tilley 2013-12-21 19:14:22 -08:00
parent 3eb5f06467
commit df3c44c6c5
7 changed files with 628 additions and 33 deletions

View File

@ -1 +1 @@
html,body{font-size:15px;font-family:"Open Sans","Helvetica Neue","Helvetica","Arial",sans-serif}body{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-family:"Source Sans Pro","Helvetica Neue","Helvetica","Arial",sans-serif}h1.subheader,h2.subheader,h3.subheader,h4.subheader,h5.subheader,h6.subheader{font-weight:300}h1.title-header,h2.title-header{margin-top:0px;margin-bottom:10px}.content.container{padding-top:50px}.centered{text-align:center}.feature-list{font-size:17px}.feature-list .icon{margin-right:5px !important}a.ui.icon.header{text-decoration:none;color:black}a.ui.icon.header:hover{color:blue}.divider .icon.huge{font-size:2em}.footer .text{text-align:center}canvas{width:350px;height:350px}@media screen and (max-width:768px){.hide-on-mobile{display:none !important}.ui.grid>.eight.wide.column{width:auto !important;min-width:100%}}@media screen and (min-width:769px){.hide-on-non-mobile{display:none !important}.main-menu .items{text-align:center;max-width:900px}}@media screen and (min-width:1050px){.main-menu{padding-left:8%}}.spacer{display:inline-block;width:50px}.ui.large.menu .item.minor{font-size:14px}.homepage-globe-canvas{text-align:right}@media screen and (max-width:998px){.homepage-globe-canvas{text-align:center}}.ui.dark.blue.label{background-color:#000080 !important}.ui.dark.blue.label:before{background-color:#000080 !important}.no-underline{text-decoration:none}
html,body{font-size:15px;font-family:"Open Sans","Helvetica Neue","Helvetica","Arial",sans-serif}body{margin:0;padding:0}h1,h2,h3,h4,h5,h6{font-family:"Source Sans Pro","Helvetica Neue","Helvetica","Arial",sans-serif}h1.subheader,h2.subheader,h3.subheader,h4.subheader,h5.subheader,h6.subheader{font-weight:300}h1.title-header,h2.title-header{margin-top:0px;margin-bottom:10px}.content.container{padding-top:50px}.content.container .slim{max-width:1108px;padding:0 20px;margin:0 auto}.centered{text-align:center}.feature-list{font-size:17px}.feature-list .icon{margin-right:5px !important}a.ui.icon.header{text-decoration:none;color:black}a.ui.icon.header:hover{color:blue}.divider .icon.huge{font-size:2em}.footer .text{text-align:center}canvas{width:350px;height:350px}@media screen and (max-width:768px){.hide-on-mobile{display:none !important}.ui.grid>.wide.column{width:auto !important;min-width:100%}}.column h1:first-child{padding-top:0;margin-top:0}@media screen and (min-width:769px){.hide-on-non-mobile{display:none !important}.main-menu .items{text-align:center;max-width:900px}}@media screen and (min-width:1050px){.main-menu{padding-left:8%}}.spacer{display:inline-block;width:50px}.ui.large.menu .item.minor{font-size:14px}.homepage-globe-canvas{text-align:right}@media screen and (max-width:998px){.homepage-globe-canvas{text-align:center}}.ui.dark.blue.label{background-color:#000080 !important}.ui.dark.blue.label:before{background-color:#000080 !important}.no-underline{text-decoration:none}.ui.menu .item.with-subitems{padding-bottom:0.2em}.ui.menu .item.contains-subitems{padding-top:0;padding-bottom:0;margin-top:0}pre{font-size:14px;overflow-x:auto}

View File

@ -0,0 +1,83 @@
<!doctype html>
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='item ' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='item ' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='item ' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='item ' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item active' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item ' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
</div>
</div>
<div class='twelve wide column'>
<h1>TopoJSON Plugin</h1>
</div>
</div>
</div>
</body>
</html>

121
documentation/core.html Normal file
View File

@ -0,0 +1,121 @@
<!doctype html>
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='item ' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='item active' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='item ' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='item ' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item ' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item ' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
</div>
</div>
<div class='twelve wide column'>
<h1>Core API</h1>
<h2>Installation</h2>
<p>Once you&#39;ve <a href="https://github.com/BinaryMuse/planetary.js/releases">downloaded Planetary.js</a>, you can include it via a <code>script</code> tag on your page <em>after</em> the inclusion of D3 and TopoJSON. This example uses the CDN URLs for those libraries:</p>
<div class='ui raised segment'>
<div class='ui blue ribbon label'>HTML</div>
<pre><code class="language-html">&lt;html&gt;
&lt;head&gt;
&lt;script type=&#39;text/javascript&#39; src=&#39;http://d3js.org/d3.v3.min.js&#39;&gt;&lt;/script&gt;
&lt;script type=&#39;text/javascript&#39; src=&#39;http://d3js.org/topojson.v1.min.js&#39;&gt;&lt;/script&gt;
&lt;script type=&#39;text/javascript&#39; src=&#39;path/to/planetaryjs.min.js&#39;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
...</code></pre>
<p></div></p>
<h2>Core API</h2>
<p><strong><code>planetaryjs.noConflict()</code></strong></p>
<p>In non-AMD and non-CommonJS environments, Planetary.js takes over the global <code>planetaryjs</code> namespace (in the browser, this means <code>window.planetaryjs</code>). If, for some reason, something else useful was there before you loaded Planetary.js, you can ask for it to be returned to that spot by calling <code>planetaryjs.noConflict()</code>. The Planetary.js library will be returned from the function, so you can continue to use the library.</p>
<div class='ui raised segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var planetary = planetaryjs.noConflict();</code></pre>
<p></div></p>
<p><strong><code>planetaryjs.loadPlugin(plugin)</code></strong></p>
<p>Planetary.js uses a plugin architecture for all its functionality. Calling <code>planetaryjs.loadPlugin</code> will cause that plugin to be loaded in <em>all</em> planets created from this library. If you only want to use a plugin in some of your planets, use the <code>planet.loadPlugin</code> method (from the <a href="/documentation/planet.html">Planet API</a>) instead.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planetaryjs.loadPlugin(somePlugin);
planetaryjs.loadPlugin(somePluginGenerator());</code></pre>
<p></div></p>
<p>For more information on the plugin system and API, please see the <a href="/documentation/plugins.html">Plugins</a> documentation.</p>
<p><strong><code>planetaryjs.planet()</code></strong></p>
<p>The <code>planet</code> API call returns a new planet instance, which represents a single globe. It will be created with all the plugins registered with <code>planetaryjs.loadPlugin()</code> active. It has various methods for manipulating the globe and drawing it to a canvas. The <a href="/documentation/planet.html">Planet API</a> covers these methods in considerably more detail.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var planet = planetaryjs.planet();</code></pre>
<p></div></p>
</div>
</div>
</div>
</body>
</html>

91
documentation/index.html Normal file
View File

@ -0,0 +1,91 @@
<!doctype html>
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='item active' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='item ' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='item ' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='item ' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item ' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item ' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
</div>
</div>
<div class='twelve wide column'>
<h1>Introduction</h1>
<p>Planetary.js is a JavaScript library for building awesome interactive globes. It uses <a href="http://d3js.org/">D3</a> and <a href="https://github.com/mbostock/topojson">TopoJSON</a> to parse and render geographic data. Planetary.js is a plugin-based system; even the default functionality is implemented as plugins! This makes Planetary.js extremely flexible.</p>
<p>The documentation is split up into several sections:</p>
<ul>
<li><a href="/documentation/core.html">Core API</a> describes the top-level Planetary.js API, including installing and configuring the library and creating new instances of planets.</li>
<li><a href="/documentation/planet.html">Planet API</a> describes the API associated with a planet instance, including modifying its properties and accessing a special canvas context that allows you to draw on the globe.</li>
<li><a href="/documentation/plugins.html">Plugins</a> describes the plugin architecture of Planetary.js and shows how you can easily build your own plugins to modify the behavior of Planetary.js</li>
<li><a href="/documentation/builtin.html">Built-In Plugins</a> describes each of the built-in plugins in turn, including their public API and how to use them in a project.</li>
</ul>
</div>
</div>
</div>
</body>
</html>

175
documentation/planet.html Normal file
View File

@ -0,0 +1,175 @@
<!doctype html>
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='item ' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='item ' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='item active' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='item ' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item ' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item ' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
</div>
</div>
<div class='twelve wide column'>
<h1>Planet API</h1>
<p>A &quot;planet&quot; represents a single globe and its rendering instructions. It is created from the <code>planetaryjs.planet()</code> method; see the <a href="/documentation/core.html">Core API</a> documentation for more details.</p>
<p><strong><code>planet.loadPlugin(plugin)</code></strong></p>
<p>Planetary.js uses a plugin architecture for all its functionality. While you can load plugins at the global library level, Planetary.js also allows you to load plugins for specific planets. <strong>If a planet is drawn and no plugins have been loaded globally and no plugins have been loaded for the specific planet instance, it will use the default <code>earth</code> and <code>pings</code> plugins.</strong></p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planet.loadPlugin(somePlugin);
planet.loadPlugin(somePluginGenerator());</code></pre>
<p></div></p>
<p>For more information on the plugin system and API, please see the <a href="/documentation/plugins.html">Plugins</a> documentation.</p>
<p><strong><code>planet.projection</code></strong></p>
<p>The core of a planet&#39;s data model is an <a href="https://github.com/mbostock/d3/wiki/Geo-Projections"><code>d3.geo.projection</code></a> (specifically, an orthographic projection), which is exposed by a planet by <code>planet.projection</code>. You can use this object to control various aspects of the planet. The D3 documentation covers the methods in considerable detail, so <a href="https://github.com/mbostock/d3/wiki/Geo-Projections">be sure to check it out</a>; many of the examples on this site also use the projection object to operate.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planet.projection
.scale(width / 2)
.rotate([60, -10, 0]);</code></pre>
<p></div></p>
<p><strong><code>planet.path</code></strong></p>
<p><code>planet.path</code> is a <a href="https://github.com/mbostock/d3/wiki/Geo-Paths"><code>d3.geo.path</code></a> which uses the planet&#39;s internal projection to generate path data for geographical features. Its <code>context</code> method is commonly used by interal plugins to take a canvas context and return a path generator that can be used to draw on the globe.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">canvasContext.beginPath();
planet.path.context(canvasContext)(geoFeature);
canvasContext.fill();</code></pre>
<p></div></p>
<p><strong><code>planet.plugins</code></strong></p>
<p>Planetary.js provides an empty object that plugins may use to store public data and methods. If a plugin is well-behaved, it will keep all its properties on the object under a single key (usually one that share&#39;s the plugin&#39;s name).</p>
<p><strong><code>planet.canvas</code> and <code>planet.context</code></strong></p>
<p>Once you call <code>draw</code> on a planet instance, Planetary.js will set the <code>canvas</code> and <code>context</code> properties to the canvas and its context, respectively.</p>
<p><strong><code>planet.onInit( function([done]){} )</code></strong></p>
<p>Registers a function to be called when the planet is initialized (which happens after a call to <code>draw</code> and after any loaded plugins have been initialized). This is mostly used by plugins to initialize themselves when the planet &quot;boots.&quot;</p>
<p>If the provided callback function takes any parameters, it will be a &quot;done&quot; function that must be called once the initialization function finishes any asynchronous work before the planet will continue to initialize.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planet.onInit(function() {
doSomeSetupStuff();
});
planet.onInit(function(done) {
doSomeAsynchronousSetupStuff(function() {
done();
});
});</code></pre>
<p></div></p>
<p><strong><code>planet.onDraw( function(){} )</code></strong></p>
<p>Registers a function to be called each time the globe redraws itself. This is mostly used by plugins to draw plugin-specific data or otherwise animate the globe.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planet.onDraw(function() {
var rotation = planet.projection.rotate();
rotation[0] += 1;
if (rotation[0] &gt;= 180) rotation[0] -= 360;
planet.projection.rotate(rotation);
});</code></pre>
<p></div></p>
<p><strong><code>planet.withSavedContext( function(context){} )</code></strong></p>
<p>Calls the function with the current canvas context as a paremter, wrapping the function call in <code>context.save()</code> and <code>context.restore()</code>. Use this function any time you&#39;re going to modify the context to ensure it gets put back to the way it was.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">planet.onDraw(function() {
planet.withSavedContext(function(context) {
context.beginPath();
planet.path.context(context)({type: &#39;Sphere&#39;});
context.fillStyle = config.fill || &#39;black&#39;;
context.fill();
});
});</code></pre>
<p></div></p>
<p><strong><code>planet.draw(canvas)</code></strong></p>
<p>Begins drawing the globe onto the given canvas. <code>canvas</code> should be a raw DOM element (e.g. as returned by <code>document.getElementById</code>). Specifically, if it is wrapped by D3 or jQuery, you need to unwrap it with something like <code>wrappedCanvas[0]</code>.</p>
<p>Calling <code>draw</code> will perform the following operations:</p>
<ol>
<li>Initialize each loaded plugin by calling the plugin function.</li>
<li>Set <code>planet.canvas</code> and <code>planet.context</code> to the canvas and the canvas&#39; context, respectively.</li>
<li>Run each registered <code>onInit</code> hook in the order it was registered (note that <code>onInit</code> calls made by plugins will not be made until step 1, after <code>draw</code> has been called).</li>
<li>Start the animation loop, each tick clearing the canvas and calling any registered <code>onDraw</code> hooks in order.</li>
</ol>
<div class='ui raise segment'>
<div class='ui blue ribbon label'>HTML</div>
<pre><code class="language-html">&lt;canvas id=&#39;myCanvas&#39; width=&#39;123&#39; height=&#39;456&#39;&gt;&lt;/canvas&gt;</code></pre>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var canvas = document.getElementById(&#39;myCanvas&#39;);
planet.draw(canvas);</code></pre>
<p></div></p>
</div>
</div>
</div>
</body>
</html>

121
documentation/plugins.html Normal file
View File

@ -0,0 +1,121 @@
<!doctype html>
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='page ui slim stackable grid'>
<div class='four wide column'>
<div class='ui fluid vertical menu'>
<a class='item ' href='/documentation/index.html'>
Introduction
<i class='icon home'></i>
</a>
<a class='item ' href='/documentation/core.html'>
Core API
<i class='icon setting'></i>
</a>
<a class='item ' href='/documentation/planet.html'>
Planet API
<i class='icon globe'></i>
</a>
<a class='item active' href='/documentation/plugins.html'>
Plugins
<i class='icon edit'></i>
</a>
<a class='item with-subitems ' href='/documentation/builtin.html'>
Built-In Plugins
<i class='icon bolt'></i>
</a>
<div class='item contains-subitems'>
<div class='menu'>
<a class='item ' href='/documentation/builtin_earth.html'>Earth</a>
<a class='item ' href='/documentation/builtin_topojson.html'>TopoJSON</a>
<a class='item ' href='/documentation/builtin_oceans.html'>Oceans</a>
<a class='item ' href='/documentation/builtin_land.html'>Land</a>
<a class='item ' href='/documentation/builtin_borders.html'>Borders</a>
<a class='item ' href='/documentation/builtin_pings.html'>Pings</a>
<a class='item ' href='/documentation/builtin_zoom.html'>Zoom</a>
<a class='item ' href='/documentation/builtin_drag.html'>Drag</a>
</div>
</div>
</div>
</div>
<div class='twelve wide column'>
<h1>Plugins</h1>
<p>Planetary.js uses a plugin-based architecture, and all the built-in functionality is built using this architecture. This makes Planetary.js extremely flexible.</p>
<h2>Loading Plugins</h2>
<p>Plugins are loaded either globally by <code>planetaryjs.loadPlugin</code> or for a specific planet instance by <code>planet.loadPlugin</code>. If you call <code>draw</code> on a planet and it has no plugins loaded at all (from either source), Planetary.js will use the default plugin stack, which consists of the <code>earth</code> and <code>pings</code> plugins.</p>
<h2>Anatomy of a Plugin</h2>
<p>A plugin is simply a JavaScript function that takes a planet instance as a parameter and performs some predefined operation. <strong>The best plugins do one tiny thing.</strong> If you want a plugin to do a lot of things at once, you should build a plugin that wraps other, smaller plugins; in fact, this is exactly how the <code>earth</code> plugin is built. See the <a href="/documentation/builtin_earth.html">Earth</a> documentation for more details.</p>
<p>Most of the time, a plugin will implement its behavior by registering callbacks into the planet&#39;s lifecycle hooks. For example, the following simple plugin increments the planet&#39;s projection&#39;s rotation by one degree every tick (this would make for a very fast spinning globe, but demonstrates the idea nicely enough):</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var autorotate = function(planet) {
planet.onDraw(function() {
var rotation = planet.projection.rotate();
rotation[0] += 1;
if (rotation[0] &gt;= 180) rotation[0] -= 360;
planet.projection.rotate(rotation);
});
};
planet.loadPlugin(autorotate);</code></pre>
<p></div></p>
<h2>Plugin Generators</h2>
<p>Often, you&#39;ll want your plugin to be configurable with some user-defined values. You can create a function generator, which is a function that takes your configuration data and then <em>returns</em> the plugin function. You can then call this generator to generate the plugin function for use by <code>loadPlugin</code>.</p>
<div class='ui raise segment'>
<div class='ui red ribbon label'>JavaScript</div>
<pre><code class="language-javascript">var autorotate = function(degreesPerTick) {
return function(planet) {
planet.onDraw(function() {
var rotation = planet.projection.rotate();
rotation[0] += degreesPerTick;
if (rotation[0] &gt;= 180) rotation[0] -= 360;
planet.projection.rotate(rotation);
});
};
};
planet.loadPlugin(autorotate(5));</code></pre>
<p></div></p>
</div>
</div>
</div>
</body>
</html>

View File

@ -2,35 +2,37 @@
<html>
<head>
<title>Planetary.js</title>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="css/planetaryjs.css">
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'>
<link type="text/css" rel="stylesheet" href="/semantic/css/semantic.min.css">
<link type="text/css" rel="stylesheet" href="/css/planetaryjs.css">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>
<div class='ui fixed inverted large menu main-menu'>
<div class='items'>
<a class='item title' href='index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='examples.html'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='examples.html'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
<div class='items'>
<a class='item title' href='/index.html'>
<i class='globe icon'></i>Planetary.js
</a>
<span class='spacer hide-on-mobile'></span>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js/releases'>
<i class='download icon'></i><span class='hide-on-mobile'>Download</span>
</a>
<a class='item minor' href='/examples/'>
<i class='laptop icon'></i><span class='hide-on-mobile'>Examples</span>
</a>
<a class='item minor' href='/documentation/'>
<i class='book icon'></i><span class='hide-on-mobile'>Documentation</span>
</a>
<a class='item minor' href='https://github.com/BinaryMuse/planetary.js'>
<i class='github alternate icon'></i><span class='hide-on-mobile'>Fork on GitHub</span>
</a>
</div>
</div>
<div class='content container'>
<div class='ui page stackable grid'>
@ -68,7 +70,7 @@
</div>
<div style='padding-top: 10px;'>
Or install with <a href='http://bower.io/'>Bower</a>: <div class='ui small label'>bower install planetary.js</div>
Or install with <a href='http://bower.io/'>Bower</a>: <div class='ui small label'><i class='icon right arrow'></i> bower install planetary.js</div>
</div>
</div>
@ -101,20 +103,20 @@
<div class='ui three column stackable divided grid center aligned'>
<div class='column'>
<a class='ui icon header' href='examples.html'>
<a class='ui icon header' href='/examples/'>
<i class='ui huge icon laptop'></i>
Examples
</a>
<p>Check out working examples and see what Planetary.js can do</p>
<p><a class='ui teal button' href='examples.html'>Explore the Examples</a></p>
<p><a class='ui teal button' href='/examples/'>Explore the Examples</a></p>
</div>
<div class='column'>
<a class='ui icon header' href='documentation.html'>
<a class='ui icon header' href='/documentation/'>
<i class='ui huge icon book'></i>
Documentation
</a>
<p>Download and install Planetary.js and build something awesome</p>
<p><a class='ui orange button' href='documentation.html'>Peruse the Documentation</a></p>
<p><a class='ui orange button' href='/documentation/'>Peruse the Documentation</a></p>
</div>
<div class='column'>
<a class='ui icon header' href='https://github.com/BinaryMuse/planetary.js'>
@ -130,9 +132,11 @@
</div>
</div>
<script type='text/javascript' src="js/lib/d3.v3.min.js"></script>
<script type='text/javascript' src="js/lib/topojson.v1.min.js"></script>
<script type="text/javascript" src="js/lib/planetaryjs.min.js"></script>
<script type='text/javascript' src="/js/lib/d3.v3.min.js"></script>
<script type='text/javascript' src="/js/lib/topojson.v1.min.js"></script>
<script type="text/javascript" src="/js/lib/planetaryjs.min.js"></script>
<script type="text/javascript" src="js/homepage.js"></script>
</body>
</html>