mirror of
https://github.com/rileyjshaw/terra.git
synced 2024-11-21 04:54:23 +00:00
Update 2014-09-27T21:48:14.531Z
This commit is contained in:
parent
5df0b3e94a
commit
f2c5b8f51c
34
index.html
34
index.html
@ -27,7 +27,7 @@
|
||||
</nav>
|
||||
|
||||
<div id="main" class="main">
|
||||
<p>terra is a <strong>super customizable</strong> library for creating and analyzing biological simulations. It's open-source and licenced under MIT.</p>
|
||||
<p>terra is a <strong>super customizable</strong> library for creating and analyzing biological simulations. It's open-source and licensed under MIT.</p>
|
||||
|
||||
<h2 id="usage">Usage</h2>
|
||||
|
||||
@ -66,7 +66,7 @@ window.terra;</code></pre>
|
||||
|
||||
<h3>Creating the environment</h3>
|
||||
<p>To run a simulation, we'll need to create an environment. Let's make a 25x25 grid, populate 10% of the space with our lonely purple creature, and fill the rest with simple plants.</p>
|
||||
<pre><code class="language-javascript">var ex1 = new terra.Terrarium(25, 25, 'ex1');
|
||||
<pre><code class="language-javascript">var ex1 = new terra.Terrarium(25, 25, {id: 'ex1'});
|
||||
ex1.grid = ex1.makeGridWithDistribution([['secondCreature', 10], ['simplePlant', 90]]);</code></pre>
|
||||
|
||||
<h3>Running a simulation</h3>
|
||||
@ -79,7 +79,10 @@ ex1.grid = ex1.makeGridWithDistribution([['secondCreature', 10], ['simplePlant',
|
||||
<h2 id="examples">Examples</h2>
|
||||
|
||||
<h3 id="gol">Conway's Game of Life <a class="question" target="_blank" href="http://en.wikipedia.org/wiki/Conway's_Game_of_Life">?</a></h3>
|
||||
<pre><code class="language-javascript">var gameOfLife = new terra.Terrarium(25, 25);
|
||||
<pre><code class="language-javascript">var gameOfLife = new terra.Terrarium(25, 25, {
|
||||
trails: 0.9,
|
||||
background: [22, 22, 22]
|
||||
});
|
||||
|
||||
terra.registerCA({
|
||||
type: 'GoL',
|
||||
@ -342,9 +345,13 @@ elementary.animate();</code></pre>
|
||||
|
||||
<h2 id="terrarium">Terrarium</h2>
|
||||
<p>Terrariums are where the action happens. They're initialized with the following constructor:</p>
|
||||
<pre><code class="language-javascript">//new terra.Terrarium(width, height, id, cellSize, insertAfter);
|
||||
<pre><code class="language-javascript">//new terra.Terrarium(width, height, {options});
|
||||
//example: create a 4x4 terrarium called #myTerrarium after element #bugStory
|
||||
var t = new terra.Terrarium(4, 4, 'myTerrarium', 15, document.getElementById('bugStory');</code></pre>
|
||||
var t = new terra.Terrarium(4, 4, {
|
||||
id: 'myTerrarium',
|
||||
cellSize: 15,
|
||||
insertAfter: document.getElementById('bugStory')
|
||||
});</code></pre>
|
||||
<h3>Required</h3>
|
||||
<ul class="defaults">
|
||||
<li>
|
||||
@ -376,6 +383,23 @@ var t = new terra.Terrarium(4, 4, 'myTerrarium', 15, document.getElementById('bu
|
||||
<li>Default: canvas is appended to <code class="language-markup">document.body</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<h4><span class="token keyword">float</span> trails</h4>
|
||||
<p>Allows for "trails", which visualize system history. A value of 1 shows all past state; trails fade faster as we approach 0.</p>
|
||||
<ul>
|
||||
<li>Range: [0, 1]</li>
|
||||
<li>Default: canvas is appended to <code class="language-markup">document.body</code></li>
|
||||
<li>Dependencies: "background" option is required if trails is set.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<h4><span class="token keyword">int [3]</span> background</h4>
|
||||
<p>RGB components of the canvas' background.</p>
|
||||
<ul>
|
||||
<li>Range: [0, 255]</li>
|
||||
<li>Default: transparent</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p id="terrariumMethods">Once initialized, terrariums have a few exposed methods. Using our terrarium <code class="language-javascript">t</code> that we just created:</p>
|
||||
|
1214
terra.demo.min.js
vendored
1214
terra.demo.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user