mirror of
https://github.com/rileyjshaw/terra.git
synced 2024-11-21 04:54:23 +00:00
Update 2014-09-02T17:41:46.034Z
This commit is contained in:
parent
19fd180be6
commit
f172764c5d
25
index.html
25
index.html
@ -156,7 +156,30 @@ terra.registerCreature({
|
||||
bbTerrarium.grid = bbTerrarium.makeGridWithDistribution([['plant', 50], ['brute', 5], ['bully', 5]]);
|
||||
bbTerrarium.animate();</code></pre>
|
||||
|
||||
<p>If you come up with a cool example, <a href="mailto:i@rileyjshaw.com">let me know</a>! I'll add it to this list and credit you.</p>
|
||||
<h3 id="rule146">Rule 146</h3>
|
||||
<pre><code class="language-javascript">var elementary = new terra.Terrarium(150, 150);
|
||||
|
||||
factory.registerCA({
|
||||
type: 'elementary',
|
||||
alive: false,
|
||||
ruleset: [1, 0, 0, 1, 0, 0, 1, 0].reverse(), // rule 146
|
||||
colorFn: function () { return this.alive ? this.color + ',1' : '0,0,0,0'; },
|
||||
process: function (neighbors, x, y) {
|
||||
if (this.age === y) {
|
||||
var index = neighbors.filter(function (neighbor) { return neighbor.coords.y === y - 1;
|
||||
}).map(function (neighbor) { return neighbor.creature.alive ? 1 : 0; });
|
||||
index = parseInt(index.join(''), 2);
|
||||
this.alive = isNaN(index) ? !x : this.ruleset[index];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
elementary.grid = elementary.makeGrid('elementary');
|
||||
elementary.animate();</code></pre>
|
||||
|
||||
|
||||
<p>If you come up with a cool example, <a href="mailto:i@rileyjshaw.com">let me know</a>! I'll add it to this list and credit you.</p>
|
||||
|
||||
<h2 id="creatures">Creatures</h2>
|
||||
<p>Creatures are registered with <pre><code class="language-javascript">terra.registerCreature(options, init)</code></pre> or <pre><code class="language-javascript">terra.registerCA(options, init)</code></pre> for cellular automata.</p>
|
||||
|
2
main.css
2
main.css
@ -1 +1 @@
|
||||
@font-face{font-family:icomoon;src:url(icomoon.eot?it882c);src:url(icomoon.eot?#iefixit882c) format('embedded-opentype'),url(icomoon.woff?it882c) format('woff'),url(icomoon.ttf?it882c) format('truetype'),url(icomoon.svg?it882c#icomoon) format('svg');font-weight:400;font-style:normal}[class*=" icon-"],[class^=icon-]{font-family:icomoon;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-play:before{content:"\e600"}.icon-stop:before{content:"\e601"}.icon-github:before{content:"\e602"}code[class*=language-],pre[class*=language-]{color:#f8f8f2;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#272822}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#f8f8f2}.namespace{opacity:.7}.token.constant,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.important{font-weight:700}.token.entity{cursor:help}.fullPage,body,html{height:100%;width:100%}body{margin:0;font-family:Open Sans,sans-serif;color:#bbb;background:#222}a{color:#bbb}a:focus{outline:0;color:#ff69b4!important}.main{line-height:1.5em;width:50%;padding-top:1.5em;margin:0 auto;font-size:24px}.main canvas{display:block;margin:1em auto}.canvasWrapper{position:relative}.canvasWrapper button{position:absolute;top:50%;left:50%;height:60px;width:60px;margin:-30px;border:0;border-radius:30px;outline:0;font-size:36px;background:rgba(255,255,255,.3);cursor:pointer}.playing .icon-play,.stopped .icon-stop{display:none}.vcent{height:100%;display:inline-block;vertical-align:middle}.sticky nav{position:fixed;top:0;left:0}.sticky .main{margin-top:60px}.splash{position:relative;overflow:hidden;font-size:0;text-align:center;background:#222}.splash canvas{position:absolute;top:0;left:0}header{z-index:1;position:relative;width:20em;display:inline-block;vertical-align:middle;font-size:1rem;color:#fff;background:rgba(0,0,0,.7)}header h1 span{vertical-align:super;font-size:16px}header p{line-height:normal;font-size:1rem}header .downArrow{display:block;font-size:24px;padding-bottom:1em;text-decoration:none;color:#fff}nav{z-index:1;height:60px;line-height:60px;width:100%;font-size:0;background:#bbb;-webkit-box-shadow:0 1px 2px #444;box-shadow:0 1px 2px #444}nav a{text-decoration:none;color:#222}nav ul{margin:0;padding:0 10%;list-style:none;font-size:1rem;text-align:justify}nav ul:after{content:"";display:inline-block;width:100%}nav li{display:inline-block}h2{margin-top:1.5em}.mono,h4{font-family:monospace;font-weight:400}.defaults,.defaults ul{list-style:none;padding-left:0}.defaults li{margin-top:1em}.defaults>li{margin-bottom:1em;padding:1em;background:#272822}.defaults h4{margin:0}.defaults p{margin:1em 0 .5em}pre{font-size:16px}a.question{font-size:18px;font-weight:700;text-decoration:none;color:#6e6e6e}footer{height:96px;line-height:96px;margin-top:5em;text-align:center;background:#111;-webkit-box-shadow:-6px 0 6px #222 inset;box-shadow:-6px 0 6px #222 inset}
|
||||
@font-face{font-family:icomoon;src:url(icomoon.eot?it882c);src:url(icomoon.eot?#iefixit882c) format('embedded-opentype'),url(icomoon.woff?it882c) format('woff'),url(icomoon.ttf?it882c) format('truetype'),url(icomoon.svg?it882c#icomoon) format('svg');font-weight:400;font-style:normal}[class*=" icon-"],[class^=icon-]{font-family:icomoon;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-play:before{content:"\e600"}.icon-stop:before{content:"\e601"}.icon-github:before{content:"\e602"}code[class*=language-],pre[class*=language-]{color:#f8f8f2;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono',monospace;direction:ltr;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#272822}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#f8f8f2}.namespace{opacity:.7}.token.constant,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.important{font-weight:700}.token.entity{cursor:help}.fullPage,body,html{height:100%;width:100%}body{margin:0;font-family:Open Sans,sans-serif;color:#bbb;background:#222}a{color:#bbb}a:focus{outline:0;color:#ff69b4!important}.main{line-height:1.5em;width:50%;padding-top:1.5em;margin:0 auto;font-size:24px}.main canvas{display:block;margin:1em auto}.canvasWrapper{position:relative}.canvasWrapper button{position:absolute;top:50%;left:50%;height:60px;width:60px;margin:-30px;border:0;border-radius:30px;outline:0;font-size:36px;background:rgba(255,255,255,.3);cursor:pointer}.playing .icon-play,.stopped .icon-stop{display:none}.vcent{height:100%;display:inline-block;vertical-align:middle}.sticky nav{position:fixed;top:0;left:0}.sticky .main{margin-top:60px}.splash{position:relative;overflow:hidden;font-size:0;text-align:center;background:#222}.splash canvas{position:absolute;top:0;left:0}header{z-index:1;position:relative;display:inline-block;vertical-align:middle;width:20em;padding:0 2em;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;font-size:1rem;color:#fff;background:rgba(0,0,0,.7)}header h1 span{vertical-align:super;font-size:16px}header p{line-height:normal;font-size:1rem}header .downArrow{display:block;font-size:24px;padding-bottom:1em;text-decoration:none;color:#fff}nav{z-index:1;height:60px;line-height:60px;width:100%;font-size:0;background:#bbb;-webkit-box-shadow:0 1px 2px #444;box-shadow:0 1px 2px #444}nav a{text-decoration:none;color:#222}nav ul{margin:0;padding:0 10%;list-style:none;font-size:1rem;text-align:justify}nav ul:after{content:"";display:inline-block;width:100%}nav li{display:inline-block}h2{margin-top:1.5em}.mono,h4{font-family:monospace;font-weight:400}.defaults,.defaults ul{list-style:none;padding-left:0}.defaults li{margin-top:1em}.defaults>li{margin-bottom:1em;padding:1em;background:#272822}.defaults h4{margin:0}.defaults p{margin:1em 0 .5em}pre{font-size:16px}a.question{font-size:18px;font-weight:700;text-decoration:none;color:#6e6e6e}footer{height:96px;line-height:96px;margin-top:5em;text-align:center;background:#111;-webkit-box-shadow:-6px 0 6px #222 inset;box-shadow:-6px 0 6px #222 inset}
|
4
terra.demo.min.js
vendored
4
terra.demo.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user