-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
103 lines (97 loc) · 4.84 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Autonomous Agents</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" type="image/png" href="./img/favicon.png">
<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans+SC:300,400' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="./css/style.css" />
</head>
<body>
<div id="canvases" class="canvases">
<canvas class="pattern" id="pattern-canvas"></canvas>
<canvas class="flow" id="flow-canvas"></canvas>
<canvas class="agents" id="agents-canvas"></canvas>
</div>
<div class="canvas-controls">
<h3>What is this?</h3>
<p>It is a study of autonomous agents based on the Chapter 6 of the excellent book <a href="http://natureofcode.com">"Nature of Code"</a> by Daniel Shiffman.</p>
<p>Applying few simple mathematical rules to the group of "agents" can result in behaviours that look surprisingly natural.</p>
<h3>Try it out:</h3>
<p>
<label>Seek mouse:</label>
<input id="control-seek" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-seek-value"></span>
</p>
<p>
<label>Flee mouse:</label>
<input id="control-flee" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-flee-value"></span>
</p>
<p>
<label>Separation:</label>
<input id="control-separate" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-separate-value"></span>
</p>
<p>
<label>Alignment:</label>
<input id="control-align" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-align-value"></span>
</p>
<p>
<label>Cohesion:</label>
<input id="control-cohere" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-cohere-value"></span>
</p>
<p>
<label>Flow field:</label>
<input id="control-flow" min="-20" max="20" type="range" class="canvas-control" />
<span id="control-flow-value"></span>
</p>
<p>
<label for="control-show-flow" class="for-checkbox">Show flow field:</label>
<input id="control-show-flow" type="checkbox" class="canvas-control" />
</p>
</div>
<a class="ribbon" href="https://github.com/kaaes/autonomous-agents"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
<script src="./js/lib/animation.js"></script>
<script src="./js/lib/vector.js"></script>
<script src="./js/lib/particle.js"></script>
<script src="./js/lib/utils.js"></script>
<script src="./js/lib/noise.js"></script>
<script src="./js/lib/QuadTree.js"></script>
<script>
var App = window.App || {};
App.elements = {
patternCanvas: document.querySelector('#pattern-canvas'),
agentsCanvas: document.querySelector('#agents-canvas'),
flowCanvas: document.querySelector('#flow-canvas'),
canvasesParent: document.querySelector('#canvases'),
forceControls: {
seek: document.querySelector('#control-seek'),
flee: document.querySelector('#control-flee'),
separate: document.querySelector('#control-separate'),
align: document.querySelector('#control-align'),
cohere: document.querySelector('#control-cohere'),
flow: document.querySelector('#control-flow')
},
forceValues: {
seek: document.querySelector('#control-seek-value'),
flee: document.querySelector('#control-flee-value'),
separate: document.querySelector('#control-separate-value'),
align: document.querySelector('#control-align-value'),
cohere: document.querySelector('#control-cohere-value'),
flow: document.querySelector('#control-flow-value')
},
showFlowField: document.querySelector('#control-show-flow'),
}
</script>
<script src="./js/pattern.js"></script>
<script src="./js/behaviors.js"></script>
<script src="./js/flowfield.js"></script>
<script src="./js/agents.js"></script>
<script src="./js/ui.js"></script>
</body>
</html>