14 | This runs avalanches on a one-dimensional lattice (that does not loop around) and
15 | renders them in a piano-roll that shows where they occur in time, the idea being to see if
16 | they might lend themselves to particle analysis.
17 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/tools-src/tasks/source-tree.js:
--------------------------------------------------------------------------------
1 |
2 | let findit = require("findit")
3 | , pth = require("path")
4 | ;
5 |
6 | function norm (root, file) {
7 | return "./" + pth.relative(root, file);
8 | }
9 |
10 | module.exports = function (root) {
11 | return new Promise((resolve, reject) => {
12 | let finder = findit(root)
13 | , tree = {}
14 | ;
15 | finder.on("directory", (file, stat) => {
16 | tree[norm(root, file)] = stat;
17 | });
18 | finder.on("file", (file, stat) => {
19 | tree[norm(root, file)] = stat;
20 | });
21 | finder.on("error", (err) => {
22 | finder.stop();
23 | reject(err);
24 | });
25 | finder.on("end", () => {
26 | resolve(tree);
27 | });
28 | });
29 | };
30 |
--------------------------------------------------------------------------------
/tools/tasks/source-tree.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var findit = require("findit"),
4 | pth = require("path");
5 |
6 | function norm(root, file) {
7 | return "./" + pth.relative(root, file);
8 | }
9 |
10 | module.exports = function (root) {
11 | return new Promise(function (resolve, reject) {
12 | var finder = findit(root),
13 | tree = {};
14 | finder.on("directory", function (file, stat) {
15 | tree[norm(root, file)] = stat;
16 | });
17 | finder.on("file", function (file, stat) {
18 | tree[norm(root, file)] = stat;
19 | });
20 | finder.on("error", function (err) {
21 | finder.stop();
22 | reject(err);
23 | });
24 | finder.on("end", function () {
25 | resolve(tree);
26 | });
27 | });
28 | };
--------------------------------------------------------------------------------
/design/bug.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/site/img/bug.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/content/img/bug.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Robin Berjon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/tools/tasks/build-project.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | var fs = require("fs-extra"),
4 | jn = require("path").join,
5 | bn = require("path").basename,
6 | rel = require("path").resolve,
7 | dn = require("path").dirname,
8 | browserify = require("browserify"),
9 | babelify = require("babelify");
10 |
11 | function task(cmd, source, target) {
12 | return new Promise(function (resolve, reject) {
13 | browserify(source, { transform: ["babelify"] }).transform(babelify).bundle().on("error", reject).pipe(fs.createWriteStream(target).on("finish", resolve));
14 | });
15 | }
16 |
17 | function buildProject(source, target) {
18 | return new Promise(function (resolve, reject) {
19 | fs.readJson(source, function (err, data) {
20 | if (err) return reject(err);
21 | var proms = [];
22 | if (data.browserify) data.browserify.forEach(function (src) {
23 | proms.push(task("browserify", rel(dn(source), src), rel(dn(target), src)));
24 | });
25 | return Promise.all(proms);
26 | });
27 | });
28 | }
29 |
30 | // XXX this is not DRY, we should have it be more generic
31 | module.exports = function (sourceDir, targetDir, tree) {
32 | var proms = [];
33 | for (var k in tree) {
34 | if (!tree[k].isDirectory() && bn(k) === "project.json") proms.push(buildProject(jn(sourceDir, k), jn(targetDir, k)));
35 | }return Promise.all(proms);
36 | };
--------------------------------------------------------------------------------
/tools-src/tasks/build-project.js:
--------------------------------------------------------------------------------
1 |
2 | let fs = require("fs-extra")
3 | , jn = require("path").join
4 | , bn = require("path").basename
5 | , rel = require("path").resolve
6 | , dn = require("path").dirname
7 | , browserify = require("browserify")
8 | , babelify = require("babelify")
9 | ;
10 |
11 | function task (cmd, source, target) {
12 | return new Promise((resolve, reject) => {
13 | browserify(source, { transform: ["babelify"]})
14 | .transform(babelify)
15 | .bundle()
16 | .on("error", reject)
17 | .pipe(fs.createWriteStream(target).on("finish", resolve))
18 | ;
19 | });
20 | }
21 |
22 | function buildProject (source, target) {
23 | return new Promise((resolve, reject) => {
24 | fs.readJson(source, (err, data) => {
25 | if (err) return reject(err);
26 | var proms = [];
27 | if (data.browserify) data.browserify.forEach((src) => {
28 | proms.push(task("browserify", rel(dn(source), src), rel(dn(target), src)));
29 | });
30 | return Promise.all(proms);
31 | });
32 | });
33 | }
34 |
35 | // XXX this is not DRY, we should have it be more generic
36 | module.exports = function (sourceDir, targetDir, tree) {
37 | var proms = [];
38 | for (let k in tree)
39 | if (!tree[k].isDirectory() && bn(k) === "project.json")
40 | proms.push(buildProject(jn(sourceDir, k), jn(targetDir, k)));
41 | return Promise.all(proms);
42 | };
43 |
--------------------------------------------------------------------------------
/content/projects/piano-roll/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | One-Dimensional Avalanche Piano Roll
6 |
7 |
8 |
9 | This project runs avalanches on one-dimensional, non-looping lattice, with varying
10 | parameters. At every time step (when a grain of sand of dropped on the pile), all the
11 | avalanches that take place mark a bar of their extend on a line beneath the lattice, and the
12 | line is moved down.
13 |
14 |
15 | The idea is to see if it lends itself to some sort of analysis at that level.
16 |
9 | Etiologies is a web site that is maintained as
10 | an open source project to which anyone
11 | can contribute. Its core goal is to «tinker with natural philosophy» using Web technologies.
12 | It is a broad remit, deliberately.
13 |
14 |
15 | The project’s tenets are:
16 |
17 |
18 |
19 | Natural philosophy is most interesting when its propositions can be implemented as code that
20 | lends itself to in silico experiments.
21 |
22 |
23 | Such code is best when it is easily tinkered with so that anyone can tweak it whichever way
24 | in order to experiment and build up intuition.
25 |
26 |
27 | It is even better if the code in question is modular and reusable, as well as documented, so
28 | that you can plug something into something else just to see what happens.
29 |
30 |
31 | These tinkerings are best if they can be shared on the Web and demonstrated directly online
32 | as
33 | «explorable
34 | explanations».
35 |
36 |
37 |
38 | My primary initial focus is on complexity and criticality, but I’m open to contributions on
39 | other topics as well.
40 |
41 |
42 | I claim no expertise. I am simply having fun and tinkering.
43 |
22 | This runs avalanches on a one-dimensional lattice (that does not loop around) and
23 | renders them in a piano-roll that shows where they occur in time, the idea being to see if
24 | they might lend themselves to particle analysis.
25 |
\n \n ");
27 |
28 | // footer
29 | $body.append("");
30 |
31 | fs.outputFile(target, $.html(), function (err) {
32 | if (err) return reject(err);
33 | resolve();
34 | });
35 | });
36 | });
37 | }
38 |
39 | // XXX this is not DRY, we should have it be more generic
40 | module.exports = function (sourceDir, targetDir, tree) {
41 | var proms = [];
42 | for (var k in tree) {
43 | if (!tree[k].isDirectory() && ext(k) === ".html") proms.push(processHTML(jn(sourceDir, k), jn(targetDir, k)));
44 | }return Promise.all(proms);
45 | };
--------------------------------------------------------------------------------
/tools-src/tasks/process-html.js:
--------------------------------------------------------------------------------
1 |
2 | let fs = require("fs-extra")
3 | , jn = require("path").join
4 | , ext = require("path").extname
5 | , whacko = require("whacko")
6 | ;
7 |
8 | function processHTML (source, target) {
9 | return new Promise((resolve, reject) => {
10 | fs.readFile(source, "utf8", (err, data) => {
11 | if (err) return reject(err);
12 | let $ = whacko.load(data)
13 | , $title = $("title")
14 | , $body = $("body")
15 | ;
16 | // change head
17 | $("meta[charset]").after('');
18 | $title.after("");
19 | $title.after("");
20 |
21 | // main
22 | let $main = $("").append($("body").contents());
23 | $body.append($main);
24 | $main.prepend($("").text($title.text()));
25 |
26 | // header
27 | $body.prepend(
28 | `
29 |
30 |
Etiologies
31 |
38 | `
39 | );
40 |
41 | // footer
42 | $body.append(
43 | ``
57 | );
58 |
59 | fs.outputFile(target, $.html(), (err) => {
60 | if (err) return reject(err);
61 | resolve();
62 | });
63 | });
64 | });
65 | }
66 |
67 | // XXX this is not DRY, we should have it be more generic
68 | module.exports = function (sourceDir, targetDir, tree) {
69 | var proms = [];
70 | for (let k in tree)
71 | if (!tree[k].isDirectory() && ext(k) === ".html")
72 | proms.push(processHTML(jn(sourceDir, k), jn(targetDir, k)));
73 | return Promise.all(proms);
74 | };
75 |
--------------------------------------------------------------------------------
/site/projects/piano-roll/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | One-Dimensional Avalanche Piano Roll
4 |
5 |
6 |
7 |
Etiologies
8 |
15 |
One-Dimensional Avalanche Piano Roll
16 |
17 | This project runs avalanches on one-dimensional, non-looping lattice, with varying
18 | parameters. At every time step (when a grain of sand of dropped on the pile), all the
19 | avalanches that take place mark a bar of their extend on a line beneath the lattice, and the
20 | line is moved down.
21 |
22 |
23 | The idea is to see if it lends itself to some sort of analysis at that level.
24 |
17 | Etiologies is a web site that is maintained as
18 | an open source project to which anyone
19 | can contribute. Its core goal is to «tinker with natural philosophy» using Web technologies.
20 | It is a broad remit, deliberately.
21 |
22 |
23 | The project’s tenets are:
24 |
25 |
26 |
27 | Natural philosophy is most interesting when its propositions can be implemented as code that
28 | lends itself to in silico experiments.
29 |
30 |
31 | Such code is best when it is easily tinkered with so that anyone can tweak it whichever way
32 | in order to experiment and build up intuition.
33 |
34 |
35 | It is even better if the code in question is modular and reusable, as well as documented, so
36 | that you can plug something into something else just to see what happens.
37 |
38 |
39 | These tinkerings are best if they can be shared on the Web and demonstrated directly online
40 | as
41 | «explorable
42 | explanations».
43 |
44 |
45 |
46 | My primary initial focus is on complexity and criticality, but I’m open to contributions on
47 | other topics as well.
48 |
49 |
50 | I claim no expertise. I am simply having fun and tinkering.
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/TODO.txt:
--------------------------------------------------------------------------------
1 |
2 | TODO:
3 | ✓ write about page
4 | - template
5 | ✓ CSS basics
6 | ✓ fonts (moved over)
7 | ✓ header and footer layout
8 | ✓ minimal support for mobile
9 | ✓ scale the iframe down
10 | ✓ position the title and nav differently
11 | ✓ add some margins for main
12 | ✓ favicon
13 | - set up basics of build
14 | ✓ 6to5
15 | ✓ templating
16 | - generating index page
17 | - news sources
18 | ✓ start rsyncing
19 | - write SOC description
20 | - definition indexer
21 | - avalanches experiment
22 | - browserify
23 | - explorable data from offline, larger runs
24 | - open questions
25 | - sticky headers
26 | - random graphs basics
27 | - the different properties of the basic random graphs
28 | - algorithms to build them
29 | - visual explanations of their properties
30 | - avalanches on various topologies
31 | - the Bak brain?
32 | - NK model
33 | - rugged landscapes
34 | - RBNs
35 | - RBNs on various topologies
36 | - the simplest s/b model
37 | - metrics on random graphs (http://arxiv.org/abs/1005.1397? SFI video Antoine Allard)
38 | - dimensions (time-like, space-like) on a graph through information theoretic notions
39 | - reading list
40 | - Calculus of Emergence implementations (ϵ-machines)
41 |
42 | BUILD SYSTEM:
43 | ✓ Babel
44 | ✓ CleanCSS
45 | ✓ browserify
46 | ✓ nodemon
47 | - CSS built to hashed component, cached forever
48 | - JS built to several hashed components, depending on the page
49 | - need to support dependencies
50 | - libs needs to be able to run in the browser but also in Node
51 | - it should be possible to run complex computations in S3 or similar
52 | - definitions and cross-linking
53 |
54 | PROJECTS:
55 | - SOC
56 | - reprise the demo for undefined
57 | - explain it a lot more
58 | - more interactive
59 | - ask questions, then answer then in code
60 | - does topology influence avalanches?
61 | - are there rules governing how long a grain of sand stays on the table?
62 | - Origins of Order notes
63 | - s/b model, a complete implementation
64 | - this might enable a tie-in with social evolution
65 | - WebLogo, port of NetLogo
66 | - see #etiologies in Evernote
67 |
68 | WRITING:
69 | - how http://www.3quarksdaily.com/3quarksdaily/2015/05/how-informative-is-the-concept-of-biological-information.html can
70 | be fixed by applying the epistemology in Calculi of Emergence
71 | - actually write up a full epistemology, based on CoE and other assumptions. It is particularly
72 | important to clarify the centrality of information and computation, with help notably from
73 | The Annotated Turing and probably from Quantum Computing Since Democritus. It may be worth
74 | pointing at issues with Deutsch's epistemology in Four Strands.
75 |
76 | ORGANISATION:
77 | - front page lists latest items and categorised items
78 | - need a section that is basically just "concepts" and the such (e.g. Criticality)
79 | - when any page has an open question, it is extracted and collated in a central list
80 | - definitions can be linked to easily
81 |
82 | INFORMATION:
83 | ✓ about page with goals
84 | - short description of self
85 | - how to contribute
86 | - reading list
87 | - list of read books and papers, with summaries
88 | - DFNs
89 |
90 | INSPIRATION:
91 | ✓ http://www.maartenlambrechts.be/the-rise-of-explorable-explanations/
92 | - http://worrydream.com/ExplorableExplanations/
93 | - http://worrydream.com/LadderOfAbstraction/
94 | - http://setosa.io/ev/
95 | - http://jackschaedler.github.io/circles-sines-signals/index.html
96 | - http://bost.ocks.org/mike/algorithms/
97 | - http://ncase.me/polygons/
98 | - http://blog.ncase.me/explorable-explanations/
99 | - http://www.redblobgames.com/pathfinding/a-star/introduction.html
100 | - http://www.redblobgames.com/articles/curved-paths/
101 | - http://pomax.github.io/bezierinfo
102 | - http://www.vizitsolutions.com/portfolio/vfield/
103 | - https://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers
104 | - http://bactra.org/notebooks/complex-networks.html
105 | - http://synaptic.juancazala.com/#
106 | - http://burakkanber.com/blog/learn-to-embrace-dinkiness/
107 | - http://worrydream.com/MediaForThinkingTheUnthinkable/
108 |
--------------------------------------------------------------------------------
/site/css/etiologies.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */iframe,img,legend{border:0}legend,td,th{padding:0}footer,header,main{max-width:960px}footer,nav ul,p.site-title{text-align:right}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0;font-family:Titillium}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}nav li,nav li a{display:inline-block}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0;font-weight:200}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}table{border-collapse:collapse;border-spacing:0}@font-face{font-family:Titillium;src:url(/fonts/titilliumweb-extralight-webfont.eot);src:url(/fonts/titilliumweb-extralight-webfont.eot?#iefix)format("embedded-opentype"),url(/fonts/titilliumweb-extralight-webfont.woff2)format("woff2"),url(/fonts/titilliumweb-extralight-webfont.woff)format("woff"),url(/fonts/titilliumweb-extralight-webfont.ttf)format("truetype");font-weight:200;font-style:normal}@font-face{font-family:Titillium;src:url(/fonts/titilliumweb-light-webfont.eot);src:url(/fonts/titilliumweb-light-webfont.eot?#iefix)format("embedded-opentype"),url(/fonts/titilliumweb-light-webfont.woff2)format("woff2"),url(/fonts/titilliumweb-light-webfont.woff)format("woff"),url(/fonts/titilliumweb-light-webfont.ttf)format("truetype");font-weight:400;font-style:normal}@font-face{font-family:Titillium;src:url(/fonts/titilliumweb-lightitalic-webfont.eot);src:url(/fonts/titilliumweb-lightitalic-webfont.eot?#iefix)format("embedded-opentype"),url(/fonts/titilliumweb-lightitalic-webfont.woff2)format("woff2"),url(/fonts/titilliumweb-lightitalic-webfont.woff)format("woff"),url(/fonts/titilliumweb-lightitalic-webfont.ttf)format("truetype");font-weight:400;font-style:italic}@font-face{font-family:Titillium;src:url(/fonts/titilliumweb-semibold-webfont.eot);src:url(/fonts/titilliumweb-semibold-webfont.eot?#iefix)format("embedded-opentype"),url(/fonts/titilliumweb-semibold-webfont.woff2)format("woff2"),url(/fonts/titilliumweb-semibold-webfont.woff)format("woff"),url(/fonts/titilliumweb-semibold-webfont.ttf)format("truetype");font-weight:700;font-style:normal}@font-face{font-family:Titillium;src:url(/fonts/titilliumweb-semibolditalic-webfont.eot);src:url(/fonts/titilliumweb-semibolditalic-webfont.eot?#iefix)format("embedded-opentype"),url(/fonts/titilliumweb-semibolditalic-webfont.woff2)format("woff2"),url(/fonts/titilliumweb-semibolditalic-webfont.woff)format("woff"),url(/fonts/titilliumweb-semibolditalic-webfont.ttf)format("truetype");font-weight:700;font-style:italic}header{margin:auto}p.site-title{margin:-125px 50px 0 0;font-size:50px;font-weight:200}nav ul{list-style-type:none;margin:5px 40px 0 0}nav li a{padding:0 10px;line-height:1;background:0 0}nav li::before{content:"・";color:silver}nav li:first-of-type::before{content:none}a{text-decoration:none;color:#0e9063;background:linear-gradient(transparent 0,transparent 60%,#fff 65%,#fdf3a1 93%,transparent 95%)}a:hover{text-decoration:underline dotted #ff7000}a:active{color:#ff7000}main{margin:100px auto}footer{margin:100px auto 20px}footer p{margin:0}.signature{font-size:20px}.signature img{vertical-align:-10px;margin-right:-40px}.license{font-size:12px}dt{font-weight:700}form{border:1px solid #0e9063}.form-line{padding:5px 10px}.form-line label{font-weight:700;display:block}.form-line.actions{text-align:right;background:#0e9063}@media (max-width:1000px){main{margin:100px 30px}iframe{width:100%}}
--------------------------------------------------------------------------------
/design/design.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Etiologi.es
7 |
8 |
92 |
93 |
94 |
95 |
96 |
Etiologies
97 |
105 |
106 |
107 |
Tinkering with Natural Philosophy
108 |
109 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
110 | ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
111 | laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
112 | voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
113 | cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
114 |
115 |
116 | The Web Platform Tests (WPT) system relies on a code-review engine known as Critic. It
117 | ties into GitHub pull requests and is much more powerful than GitHub’s built-in code
118 | review.
119 |
120 |
121 | Most groups likely do not need Critic, but for more complex code such as that which is
122 | found in tests it is a very welcome improvement.
123 |
124 |
125 | The current Critic instance is run by
126 | James Graham on his personal server, and without HTTPS. While that is not the end of the
127 | world, given how central Critic is to the testing work it would be much better to host
128 | it on W3C.
129 |
130 |
131 | It may be worth investigating the use of Reviewable
132 | as a potential hosted replacement.
133 |
134 |
135 |
149 |
150 |
151 |
--------------------------------------------------------------------------------
/site/js/leaves.min.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o path:not(.bark)"),barks=document.querySelectorAll("path.bark"),colours=randomColor({hue:"green",count:leaves.length}),barkColours=randomColor({hue:"orange",count:barks.length});for(var i=0,n=leaves.length;icolors.length){colors.push(randomColor(options))}options.count=totalColors;return colors}H=pickHue(options);S=pickSaturation(H,options);B=pickBrightness(H,S,options);return setFormat([H,S,B],options)};function pickHue(options){var hueRange=getHueRange(options.hue),hue=randomWithin(hueRange);if(hue<0){hue=360+hue}return hue}function pickSaturation(hue,options){if(options.luminosity==="random"){return randomWithin([0,100])}if(options.hue==="monochrome"){return 0}var saturationRange=getSaturationRange(hue);var sMin=saturationRange[0],sMax=saturationRange[1];switch(options.luminosity){case"bright":sMin=55;break;case"dark":sMin=sMax-10;break;case"light":sMax=55;break}return randomWithin([sMin,sMax])}function pickBrightness(H,S,options){var brightness,bMin=getMinimumBrightness(H,S),bMax=100;switch(options.luminosity){case"dark":bMax=bMin+20;break;case"light":bMin=(bMax+bMin)/2;break;case"random":bMin=0;bMax=100;break}return randomWithin([bMin,bMax])}function setFormat(hsv,options){switch(options.format){case"hsvArray":return hsv;case"hslArray":return HSVtoHSL(hsv);case"hsl":var hsl=HSVtoHSL(hsv);return"hsl("+hsl[0]+", "+hsl[1]+"%, "+hsl[2]+"%)";case"rgbArray":return HSVtoRGB(hsv);case"rgb":var rgb=HSVtoRGB(hsv);return"rgb("+rgb.join(", ")+")";default:return HSVtoHex(hsv)}}function getMinimumBrightness(H,S){var lowerBounds=getColorInfo(H).lowerBounds;for(var i=0;i=s1&&S<=s2){var m=(v2-v1)/(s2-s1),b=v1-m*s1;return m*S+b}}return 0}function getHueRange(colorInput){if(typeof parseInt(colorInput)==="number"){var number=parseInt(colorInput);if(number<360&&number>0){return[number,number]}}if(typeof colorInput==="string"){if(colorDictionary[colorInput]){var color=colorDictionary[colorInput];if(color.hueRange){return color.hueRange}}}return[0,360]}function getSaturationRange(hue){return getColorInfo(hue).saturationRange}function getColorInfo(hue){if(hue>=334&&hue<=360){hue-=360}for(var colorName in colorDictionary){var color=colorDictionary[colorName];if(color.hueRange&&hue>=color.hueRange[0]&&hue<=color.hueRange[1]){return colorDictionary[colorName]}}return"Color not found"}function randomWithin(range){return Math.floor(range[0]+Math.random()*(range[1]+1-range[0]))}function HSVtoHex(hsv){var rgb=HSVtoRGB(hsv);function componentToHex(c){var hex=c.toString(16);return hex.length==1?"0"+hex:hex}var hex="#"+componentToHex(rgb[0])+componentToHex(rgb[1])+componentToHex(rgb[2]);return hex}function defineColor(name,hueRange,lowerBounds){var sMin=lowerBounds[0][0],sMax=lowerBounds[lowerBounds.length-1][0],bMin=lowerBounds[lowerBounds.length-1][1],bMax=lowerBounds[0][1];colorDictionary[name]={hueRange:hueRange,lowerBounds:lowerBounds,saturationRange:[sMin,sMax],brightnessRange:[bMin,bMax]}}function loadColorBounds(){defineColor("monochrome",null,[[0,0],[100,0]]);defineColor("red",[-26,18],[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]);defineColor("orange",[19,46],[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]);defineColor("yellow",[47,62],[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]);defineColor("green",[63,178],[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]);defineColor("blue",[179,257],[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]);defineColor("purple",[258,282],[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]);defineColor("pink",[283,334],[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]])}function HSVtoRGB(hsv){var h=hsv[0];if(h===0){h=1}if(h===360){h=359}h=h/360;var s=hsv[1]/100,v=hsv[2]/100;var h_i=Math.floor(h*6),f=h*6-h_i,p=v*(1-s),q=v*(1-f*s),t=v*(1-(1-f)*s),r=256,g=256,b=256;switch(h_i){case 0:r=v,g=t,b=p;break;case 1:r=q,g=v,b=p;break;case 2:r=p,g=v,b=t;break;case 3:r=p,g=q,b=v;break;case 4:r=t,g=p,b=v;break;case 5:r=v,g=p,b=q;break}var result=[Math.floor(r*255),Math.floor(g*255),Math.floor(b*255)];return result}function HSVtoHSL(hsv){var h=hsv[0],s=hsv[1]/100,v=hsv[2]/100,k=(2-s)*v;return[h,Math.round(s*v/(k<1?k:2-k)*1e4)/100,k/2*100]}return randomColor})},{}]},{},[1]);
--------------------------------------------------------------------------------
/design/randomColor.js:
--------------------------------------------------------------------------------
1 | ;(function(root, factory) {
2 |
3 | // Support AMD
4 | if (typeof define === 'function' && define.amd) {
5 | define([], factory);
6 |
7 | // Support CommonJS
8 | } else if (typeof exports === 'object') {
9 | var randomColor = factory();
10 |
11 | // Support NodeJS & Component, which allow module.exports to be a function
12 | if (typeof module === 'object' && module && module.exports) {
13 | exports = module.exports = randomColor;
14 | }
15 |
16 | // Support CommonJS 1.1.1 spec
17 | exports.randomColor = randomColor;
18 |
19 | // Support vanilla script loading
20 | } else {
21 | root.randomColor = factory();
22 | };
23 |
24 | }(this, function() {
25 |
26 | // Shared color dictionary
27 | var colorDictionary = {};
28 |
29 | // Populate the color dictionary
30 | loadColorBounds();
31 |
32 | var randomColor = function(options) {
33 | options = options || {};
34 |
35 | var H,S,B;
36 |
37 | // Check if we need to generate multiple colors
38 | if (options.count != null) {
39 |
40 | var totalColors = options.count,
41 | colors = [];
42 |
43 | options.count = null;
44 |
45 | while (totalColors > colors.length) {
46 | colors.push(randomColor(options));
47 | }
48 |
49 | options.count = totalColors;
50 |
51 | return colors;
52 | }
53 |
54 | // First we pick a hue (H)
55 | H = pickHue(options);
56 |
57 | // Then use H to determine saturation (S)
58 | S = pickSaturation(H, options);
59 |
60 | // Then use S and H to determine brightness (B).
61 | B = pickBrightness(H, S, options);
62 |
63 | // Then we return the HSB color in the desired format
64 | return setFormat([H,S,B], options);
65 | };
66 |
67 | function pickHue (options) {
68 |
69 | var hueRange = getHueRange(options.hue),
70 | hue = randomWithin(hueRange);
71 |
72 | // Instead of storing red as two seperate ranges,
73 | // we group them, using negative numbers
74 | if (hue < 0) {hue = 360 + hue}
75 |
76 | return hue;
77 |
78 | }
79 |
80 | function pickSaturation (hue, options) {
81 |
82 | if (options.luminosity === 'random') {
83 | return randomWithin([0,100]);
84 | }
85 |
86 | if (options.hue === 'monochrome') {
87 | return 0;
88 | }
89 |
90 | var saturationRange = getSaturationRange(hue);
91 |
92 | var sMin = saturationRange[0],
93 | sMax = saturationRange[1];
94 |
95 | switch (options.luminosity) {
96 |
97 | case 'bright':
98 | sMin = 55;
99 | break;
100 |
101 | case 'dark':
102 | sMin = sMax - 10;
103 | break;
104 |
105 | case 'light':
106 | sMax = 55;
107 | break;
108 | }
109 |
110 | return randomWithin([sMin, sMax]);
111 |
112 | }
113 |
114 | function pickBrightness (H, S, options) {
115 |
116 | var brightness,
117 | bMin = getMinimumBrightness(H, S),
118 | bMax = 100;
119 |
120 | switch (options.luminosity) {
121 |
122 | case 'dark':
123 | bMax = bMin + 20;
124 | break;
125 |
126 | case 'light':
127 | bMin = (bMax + bMin)/2;
128 | break;
129 |
130 | case 'random':
131 | bMin = 0;
132 | bMax = 100;
133 | break;
134 | }
135 |
136 | return randomWithin([bMin, bMax]);
137 |
138 | }
139 |
140 | function setFormat (hsv, options) {
141 |
142 | switch (options.format) {
143 |
144 | case 'hsvArray':
145 | return hsv;
146 |
147 | case 'hslArray':
148 | return HSVtoHSL(hsv);
149 |
150 | case 'hsl':
151 | var hsl = HSVtoHSL(hsv);
152 | return 'hsl('+hsl[0]+', '+hsl[1]+'%, '+hsl[2]+'%)';
153 |
154 | case 'rgbArray':
155 | return HSVtoRGB(hsv);
156 |
157 | case 'rgb':
158 | var rgb = HSVtoRGB(hsv);
159 | return 'rgb(' + rgb.join(', ') + ')';
160 |
161 | default:
162 | return HSVtoHex(hsv);
163 | }
164 |
165 | }
166 |
167 | function getMinimumBrightness(H, S) {
168 |
169 | var lowerBounds = getColorInfo(H).lowerBounds;
170 |
171 | for (var i = 0; i < lowerBounds.length - 1; i++) {
172 |
173 | var s1 = lowerBounds[i][0],
174 | v1 = lowerBounds[i][1];
175 |
176 | var s2 = lowerBounds[i+1][0],
177 | v2 = lowerBounds[i+1][1];
178 |
179 | if (S >= s1 && S <= s2) {
180 |
181 | var m = (v2 - v1)/(s2 - s1),
182 | b = v1 - m*s1;
183 |
184 | return m*S + b;
185 | }
186 |
187 | }
188 |
189 | return 0;
190 | }
191 |
192 | function getHueRange (colorInput) {
193 |
194 | if (typeof parseInt(colorInput) === 'number') {
195 |
196 | var number = parseInt(colorInput);
197 |
198 | if (number < 360 && number > 0) {
199 | return [number, number];
200 | }
201 |
202 | }
203 |
204 | if (typeof colorInput === 'string') {
205 |
206 | if (colorDictionary[colorInput]) {
207 | var color = colorDictionary[colorInput];
208 | if (color.hueRange) {return color.hueRange}
209 | }
210 | }
211 |
212 | return [0,360];
213 |
214 | }
215 |
216 | function getSaturationRange (hue) {
217 | return getColorInfo(hue).saturationRange;
218 | }
219 |
220 | function getColorInfo (hue) {
221 |
222 | // Maps red colors to make picking hue easier
223 | if (hue >= 334 && hue <= 360) {
224 | hue-= 360;
225 | }
226 |
227 | for (var colorName in colorDictionary) {
228 | var color = colorDictionary[colorName];
229 | if (color.hueRange &&
230 | hue >= color.hueRange[0] &&
231 | hue <= color.hueRange[1]) {
232 | return colorDictionary[colorName];
233 | }
234 | } return 'Color not found';
235 | }
236 |
237 | function randomWithin (range) {
238 | return Math.floor(range[0] + Math.random()*(range[1] + 1 - range[0]));
239 | }
240 |
241 | function HSVtoHex (hsv){
242 |
243 | var rgb = HSVtoRGB(hsv);
244 |
245 | function componentToHex(c) {
246 | var hex = c.toString(16);
247 | return hex.length == 1 ? "0" + hex : hex;
248 | }
249 |
250 | var hex = "#" + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
251 |
252 | return hex;
253 |
254 | }
255 |
256 | function defineColor (name, hueRange, lowerBounds) {
257 |
258 | var sMin = lowerBounds[0][0],
259 | sMax = lowerBounds[lowerBounds.length - 1][0],
260 |
261 | bMin = lowerBounds[lowerBounds.length - 1][1],
262 | bMax = lowerBounds[0][1];
263 |
264 | colorDictionary[name] = {
265 | hueRange: hueRange,
266 | lowerBounds: lowerBounds,
267 | saturationRange: [sMin, sMax],
268 | brightnessRange: [bMin, bMax]
269 | };
270 |
271 | }
272 |
273 | function loadColorBounds () {
274 |
275 | defineColor(
276 | 'monochrome',
277 | null,
278 | [[0,0],[100,0]]
279 | );
280 |
281 | defineColor(
282 | 'red',
283 | [-26,18],
284 | [[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
285 | );
286 |
287 | defineColor(
288 | 'orange',
289 | [19,46],
290 | [[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
291 | );
292 |
293 | defineColor(
294 | 'yellow',
295 | [47,62],
296 | [[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
297 | );
298 |
299 | defineColor(
300 | 'green',
301 | [63,178],
302 | [[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
303 | );
304 |
305 | defineColor(
306 | 'blue',
307 | [179, 257],
308 | [[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
309 | );
310 |
311 | defineColor(
312 | 'purple',
313 | [258, 282],
314 | [[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
315 | );
316 |
317 | defineColor(
318 | 'pink',
319 | [283, 334],
320 | [[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
321 | );
322 |
323 | }
324 |
325 | function HSVtoRGB (hsv) {
326 |
327 | // this doesn't work for the values of 0 and 360
328 | // here's the hacky fix
329 | var h = hsv[0];
330 | if (h === 0) {h = 1}
331 | if (h === 360) {h = 359}
332 |
333 | // Rebase the h,s,v values
334 | h = h/360;
335 | var s = hsv[1]/100,
336 | v = hsv[2]/100;
337 |
338 | var h_i = Math.floor(h*6),
339 | f = h * 6 - h_i,
340 | p = v * (1 - s),
341 | q = v * (1 - f*s),
342 | t = v * (1 - (1 - f)*s),
343 | r = 256,
344 | g = 256,
345 | b = 256;
346 |
347 | switch(h_i) {
348 | case 0: r = v, g = t, b = p; break;
349 | case 1: r = q, g = v, b = p; break;
350 | case 2: r = p, g = v, b = t; break;
351 | case 3: r = p, g = q, b = v; break;
352 | case 4: r = t, g = p, b = v; break;
353 | case 5: r = v, g = p, b = q; break;
354 | }
355 | var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
356 | return result;
357 | }
358 |
359 | function HSVtoHSL (hsv) {
360 | var h = hsv[0],
361 | s = hsv[1]/100,
362 | v = hsv[2]/100,
363 | k = (2-s)*v;
364 |
365 | return [
366 | h,
367 | Math.round(s*v / (k<1 ? k : 2-k) * 10000) / 100,
368 | k/2 * 100
369 | ];
370 | }
371 |
372 | return randomColor;
373 | }));
374 |
--------------------------------------------------------------------------------
/site/js/leaves.js:
--------------------------------------------------------------------------------
1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o path:not(.bark)"),
6 | barks = document.querySelectorAll("path.bark")
7 | // hue: red, orange, yellow, green, blue, purple, pink, monochrome
8 | // luminosity: light
9 | ,
10 | colours = randomColor({ hue: "green", count: leaves.length }),
11 | barkColours = randomColor({ hue: "orange", count: barks.length });
12 | for (var i = 0, n = leaves.length; i < n; i++) {
13 | leaves[i].setAttributeNS(null, "fill", colours[i]);
14 | }for (var i = 0, n = barks.length; i < n; i++) {
15 | barks[i].setAttributeNS(null, "fill", barkColours[i]);
16 | }
17 |
18 | },{"randomcolor":2}],2:[function(require,module,exports){
19 | ;(function(root, factory) {
20 |
21 | // Support AMD
22 | if (typeof define === 'function' && define.amd) {
23 | define([], factory);
24 |
25 | // Support CommonJS
26 | } else if (typeof exports === 'object') {
27 | var randomColor = factory();
28 |
29 | // Support NodeJS & Component, which allow module.exports to be a function
30 | if (typeof module === 'object' && module && module.exports) {
31 | exports = module.exports = randomColor;
32 | }
33 |
34 | // Support CommonJS 1.1.1 spec
35 | exports.randomColor = randomColor;
36 |
37 | // Support vanilla script loading
38 | } else {
39 | root.randomColor = factory();
40 | };
41 |
42 | }(this, function() {
43 |
44 | // Shared color dictionary
45 | var colorDictionary = {};
46 |
47 | // Populate the color dictionary
48 | loadColorBounds();
49 |
50 | var randomColor = function(options) {
51 | options = options || {};
52 |
53 | var H,S,B;
54 |
55 | // Check if we need to generate multiple colors
56 | if (options.count != null) {
57 |
58 | var totalColors = options.count,
59 | colors = [];
60 |
61 | options.count = null;
62 |
63 | while (totalColors > colors.length) {
64 | colors.push(randomColor(options));
65 | }
66 |
67 | options.count = totalColors;
68 |
69 | return colors;
70 | }
71 |
72 | // First we pick a hue (H)
73 | H = pickHue(options);
74 |
75 | // Then use H to determine saturation (S)
76 | S = pickSaturation(H, options);
77 |
78 | // Then use S and H to determine brightness (B).
79 | B = pickBrightness(H, S, options);
80 |
81 | // Then we return the HSB color in the desired format
82 | return setFormat([H,S,B], options);
83 | };
84 |
85 | function pickHue (options) {
86 |
87 | var hueRange = getHueRange(options.hue),
88 | hue = randomWithin(hueRange);
89 |
90 | // Instead of storing red as two seperate ranges,
91 | // we group them, using negative numbers
92 | if (hue < 0) {hue = 360 + hue}
93 |
94 | return hue;
95 |
96 | }
97 |
98 | function pickSaturation (hue, options) {
99 |
100 | if (options.luminosity === 'random') {
101 | return randomWithin([0,100]);
102 | }
103 |
104 | if (options.hue === 'monochrome') {
105 | return 0;
106 | }
107 |
108 | var saturationRange = getSaturationRange(hue);
109 |
110 | var sMin = saturationRange[0],
111 | sMax = saturationRange[1];
112 |
113 | switch (options.luminosity) {
114 |
115 | case 'bright':
116 | sMin = 55;
117 | break;
118 |
119 | case 'dark':
120 | sMin = sMax - 10;
121 | break;
122 |
123 | case 'light':
124 | sMax = 55;
125 | break;
126 | }
127 |
128 | return randomWithin([sMin, sMax]);
129 |
130 | }
131 |
132 | function pickBrightness (H, S, options) {
133 |
134 | var brightness,
135 | bMin = getMinimumBrightness(H, S),
136 | bMax = 100;
137 |
138 | switch (options.luminosity) {
139 |
140 | case 'dark':
141 | bMax = bMin + 20;
142 | break;
143 |
144 | case 'light':
145 | bMin = (bMax + bMin)/2;
146 | break;
147 |
148 | case 'random':
149 | bMin = 0;
150 | bMax = 100;
151 | break;
152 | }
153 |
154 | return randomWithin([bMin, bMax]);
155 |
156 | }
157 |
158 | function setFormat (hsv, options) {
159 |
160 | switch (options.format) {
161 |
162 | case 'hsvArray':
163 | return hsv;
164 |
165 | case 'hslArray':
166 | return HSVtoHSL(hsv);
167 |
168 | case 'hsl':
169 | var hsl = HSVtoHSL(hsv);
170 | return 'hsl('+hsl[0]+', '+hsl[1]+'%, '+hsl[2]+'%)';
171 |
172 | case 'rgbArray':
173 | return HSVtoRGB(hsv);
174 |
175 | case 'rgb':
176 | var rgb = HSVtoRGB(hsv);
177 | return 'rgb(' + rgb.join(', ') + ')';
178 |
179 | default:
180 | return HSVtoHex(hsv);
181 | }
182 |
183 | }
184 |
185 | function getMinimumBrightness(H, S) {
186 |
187 | var lowerBounds = getColorInfo(H).lowerBounds;
188 |
189 | for (var i = 0; i < lowerBounds.length - 1; i++) {
190 |
191 | var s1 = lowerBounds[i][0],
192 | v1 = lowerBounds[i][1];
193 |
194 | var s2 = lowerBounds[i+1][0],
195 | v2 = lowerBounds[i+1][1];
196 |
197 | if (S >= s1 && S <= s2) {
198 |
199 | var m = (v2 - v1)/(s2 - s1),
200 | b = v1 - m*s1;
201 |
202 | return m*S + b;
203 | }
204 |
205 | }
206 |
207 | return 0;
208 | }
209 |
210 | function getHueRange (colorInput) {
211 |
212 | if (typeof parseInt(colorInput) === 'number') {
213 |
214 | var number = parseInt(colorInput);
215 |
216 | if (number < 360 && number > 0) {
217 | return [number, number];
218 | }
219 |
220 | }
221 |
222 | if (typeof colorInput === 'string') {
223 |
224 | if (colorDictionary[colorInput]) {
225 | var color = colorDictionary[colorInput];
226 | if (color.hueRange) {return color.hueRange}
227 | }
228 | }
229 |
230 | return [0,360];
231 |
232 | }
233 |
234 | function getSaturationRange (hue) {
235 | return getColorInfo(hue).saturationRange;
236 | }
237 |
238 | function getColorInfo (hue) {
239 |
240 | // Maps red colors to make picking hue easier
241 | if (hue >= 334 && hue <= 360) {
242 | hue-= 360;
243 | }
244 |
245 | for (var colorName in colorDictionary) {
246 | var color = colorDictionary[colorName];
247 | if (color.hueRange &&
248 | hue >= color.hueRange[0] &&
249 | hue <= color.hueRange[1]) {
250 | return colorDictionary[colorName];
251 | }
252 | } return 'Color not found';
253 | }
254 |
255 | function randomWithin (range) {
256 | return Math.floor(range[0] + Math.random()*(range[1] + 1 - range[0]));
257 | }
258 |
259 | function HSVtoHex (hsv){
260 |
261 | var rgb = HSVtoRGB(hsv);
262 |
263 | function componentToHex(c) {
264 | var hex = c.toString(16);
265 | return hex.length == 1 ? "0" + hex : hex;
266 | }
267 |
268 | var hex = "#" + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
269 |
270 | return hex;
271 |
272 | }
273 |
274 | function defineColor (name, hueRange, lowerBounds) {
275 |
276 | var sMin = lowerBounds[0][0],
277 | sMax = lowerBounds[lowerBounds.length - 1][0],
278 |
279 | bMin = lowerBounds[lowerBounds.length - 1][1],
280 | bMax = lowerBounds[0][1];
281 |
282 | colorDictionary[name] = {
283 | hueRange: hueRange,
284 | lowerBounds: lowerBounds,
285 | saturationRange: [sMin, sMax],
286 | brightnessRange: [bMin, bMax]
287 | };
288 |
289 | }
290 |
291 | function loadColorBounds () {
292 |
293 | defineColor(
294 | 'monochrome',
295 | null,
296 | [[0,0],[100,0]]
297 | );
298 |
299 | defineColor(
300 | 'red',
301 | [-26,18],
302 | [[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
303 | );
304 |
305 | defineColor(
306 | 'orange',
307 | [19,46],
308 | [[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
309 | );
310 |
311 | defineColor(
312 | 'yellow',
313 | [47,62],
314 | [[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
315 | );
316 |
317 | defineColor(
318 | 'green',
319 | [63,178],
320 | [[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
321 | );
322 |
323 | defineColor(
324 | 'blue',
325 | [179, 257],
326 | [[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
327 | );
328 |
329 | defineColor(
330 | 'purple',
331 | [258, 282],
332 | [[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
333 | );
334 |
335 | defineColor(
336 | 'pink',
337 | [283, 334],
338 | [[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
339 | );
340 |
341 | }
342 |
343 | function HSVtoRGB (hsv) {
344 |
345 | // this doesn't work for the values of 0 and 360
346 | // here's the hacky fix
347 | var h = hsv[0];
348 | if (h === 0) {h = 1}
349 | if (h === 360) {h = 359}
350 |
351 | // Rebase the h,s,v values
352 | h = h/360;
353 | var s = hsv[1]/100,
354 | v = hsv[2]/100;
355 |
356 | var h_i = Math.floor(h*6),
357 | f = h * 6 - h_i,
358 | p = v * (1 - s),
359 | q = v * (1 - f*s),
360 | t = v * (1 - (1 - f)*s),
361 | r = 256,
362 | g = 256,
363 | b = 256;
364 |
365 | switch(h_i) {
366 | case 0: r = v, g = t, b = p; break;
367 | case 1: r = q, g = v, b = p; break;
368 | case 2: r = p, g = v, b = t; break;
369 | case 3: r = p, g = q, b = v; break;
370 | case 4: r = t, g = p, b = v; break;
371 | case 5: r = v, g = p, b = q; break;
372 | }
373 | var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
374 | return result;
375 | }
376 |
377 | function HSVtoHSL (hsv) {
378 | var h = hsv[0],
379 | s = hsv[1]/100,
380 | v = hsv[2]/100,
381 | k = (2-s)*v;
382 |
383 | return [
384 | h,
385 | Math.round(s*v / (k<1 ? k : 2-k) * 10000) / 100,
386 | k/2 * 100
387 | ];
388 | }
389 |
390 | return randomColor;
391 | }));
392 |
393 | },{}]},{},[1]);
394 |
--------------------------------------------------------------------------------
/tools/build-site.js:
--------------------------------------------------------------------------------
1 |
2 | // load up Babel
3 | "use strict";
4 |
5 | require("babel/polyfill");
6 |
7 | var jn = require("path").join,
8 | rel = require("./utils/rel")(jn(__dirname, "..")),
9 | contentDir = rel("content"),
10 | siteDir = rel("site"),
11 | sourceTree = require("./tasks/source-tree"),
12 | copyTree = require("./tasks/copy-tree"),
13 | copyStatic = require("./tasks/copy-static"),
14 | processHTML = require("./tasks/process-html"),
15 | buildProject = require("./tasks/build-project"),
16 | tree = undefined;
17 |
18 | sourceTree(contentDir).then(function (t) {
19 | tree = t;
20 | }).then(function () {
21 | return copyTree(siteDir, tree);
22 | }).then(function () {
23 | return copyStatic(contentDir, siteDir, tree);
24 | }).then(function () {
25 | return processHTML(contentDir, siteDir, tree);
26 | }).then(function () {
27 | return buildProject(contentDir, siteDir, tree);
28 | }).then(function () {
29 | console.log("Ok!");
30 | })["catch"](function (err) {
31 | console.error("BOOM", err);
32 | });
33 |
34 | // build output directory tree
35 | // copy all non-HTML
36 | // process all HTML
37 | // - templates
38 |
39 | // var fs = require("fs-extra")
40 | // , pth = require("path")
41 | // , crypto = require("crypto")
42 | // , findit = require("findit")
43 | // , async = require("async")
44 | // , whacko = require("whacko")
45 | // , CleanCSS = require("clean-css")
46 | // // , nopt = require("nopt")
47 | // // , knownOpts = {
48 | // // "force": Boolean
49 | // // }
50 | // // , shortHands = {
51 | // // "f" : ["--force"]
52 | // // }
53 | // // , parsedOpt = nopt(knownOpts, shortHands)
54 | // , rel = function (to) { return pth.join(__dirname, to); }
55 | // , rfs = function (file) { return fs.readFileSync(file, "utf8"); }
56 | // , wfs = function (file, content) { fs.writeFileSync(file, content, { encoding: "utf8" }); }
57 | // , norm = function (str) { return str.replace(/\s+/g, " ").replace(/(^\s+|\s+$)/g, ""); }
58 | // , escAttr = function (str) { return str.replace(/&/g, "&").replace(/"/g, """); }
59 | // , escXML = function (str) { return str.replace(/&/g, "&").replace(/ Copying .............. " + output.replace(publishDir, ""));
90 | // fs.copySync(input, output);
91 | // }
92 | //
93 | // // process HTML source file
94 | // function processHTML (input, output) {
95 | // console.log("> Processing ........... " + output.replace(publishDir, ""));
96 | // var $ = whacko.load(rfs(input))
97 | // , $tmpl = whacko.load(rfs(pth.join(tmplDir, "page.html")))
98 | // , $html = $tmpl("html")
99 | // ;
100 | // // if ($("html").attr("skip")) return copyFile(input, output);
101 | // if ($("html").attr("skip")) return wfs(output, rfs(input).replace(/\s+skip=['"]?true['"]?/, ""));
102 | // var doc = {
103 | // lang: $("html").attr("lang") || "en"
104 | // , title: $("h1").html()
105 | // , subtitle: $("h2").html()
106 | // , date: $("html").attr("date")
107 | // , blurb: $("div.blurb").length ? $("div.blurb").html() : "