-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
194 lines (149 loc) · 3.51 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>The Game of Life</title>
</head>
<link href='http://fonts.googleapis.com/css?family=PT+Sans+Narrow|Chewy' rel='stylesheet' type='text/css'>
<style type="text/css">
html {
background: #333;
};
* {
margin: 0;
padding: 0;
}
hr {
width: 100%;
border-top: 2px solid #ccc;
margin-bottom: 20px;
}
.impExample hr {
border-top: solid 1px #ccc;
}
body {
font-family: 'PT Sans Narrow', sans-serif;
margin: 15px;
font-size: 14px;
overflow: scroll;
color: #fff;
}
h1, h2, h3, h4, h5 {
font-family: 'Chewy', cursive;
margin-bottom: 5px;
}
h3 {
margin-bottom: 0;
}
.impExample {
margin: 25px 0;
}
.impExample h3 {
}
.alive {
color: red;
}
#pre {
background: none!important;
width: auto;
font-size: 9px;
}
#canvas {
border: 1px solid #999;
}
.btn {
display: inline-block;
text-decoration: none;
padding: 5px 10px;
margin: 2px 0;
background: rgba( 51, 102, 255, 0.7 );
color: #fff;
}
.btn:hover {
background: rgba( 51, 70, 255, 0.7 );
}
.btn-green {
background: rgba( 51, 255, 90, 0.7 );
}
.btn-green:hover {
background: rgba( 100, 255, 90, 0.7 );
}
.btn-red {
background: rgba( 255, 61, 61, 0.7 );
}
.btn-red:hover {
background: rgba( 255, 90, 61, 0.7 );
}
.ctrl {
margin: 0 0 10px 0;
}
</style>
<body>
<h1>Conway's Game of Life</h1>
<hr />
<p>This is a demo of the code in action! Multiple display outputs are supported, maybe it could also be ported to the desktop on top of something like GNUGuile or NodeJS.</p>
<ol>
<li>Begin by pressing the <i>start</i> button. This generates some seed data for the simulation and feeds it to the engine kickstarting the process.</li>
<li>Pressing <i>suspend</i> does not clear the simulation data but rather pauses it's execution. It can be resumed by pressing <i>start</i> again.</li>
<li>Pressing <i>rebuild</i> generates a new random seed matrix feeding it back into the engine and clearing any exisitng data.</li>
</ol>
<div class='container'>
<!-- the ui control element -->
<div class='ctrl'>
<a href="#" class='btn btn-green' id='start'>Start</a>
<a href="#" class='btn btn-red' id='stop'>Suspend</a>
<a href="#" class='btn' id='create'>Rebuild</a>
</div>
<!-- the canvas element -->
<div class='impExample'>
<h3>With HTML5 Canvas</h3>
<hr />
<canvas id="canvas"></canvas>
</div>
<div class='impExample'>
<h3>Plain old HTML...</h3>
<hr />
<pre id="pre">Waiting to begin...</pre>
</div>
</div>
<!-- inlcude javascript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="dist/game-of-life.js"></script>
<script type="text/javascript">
var SIM;
// wrap init in window load funtion
$(window).load(function () {
// setup simulator
simHTML5 = new GolController({
'canvas' : 'canvas',
'selector' : 'canvas',
'width' : 100,
'height' : 100,
'scale' : 5,
'seed_density' : 10
}),
simHTML = new GolController({
'canvas' : 'pre',
'selector' : 'pre',
'display' : 'HTML',
'width' : 70,
'height' : 70,
'seed_density' : 30
});
// build control interface
$("#start").click( function () {
simHTML5.run();
simHTML.run();
});
$("#stop").click( function () {
simHTML5.pause();
simHTML.pause();
});
$("#create").click( function () {
simHTML5.rebuild();
simHTML.rebuild();
});
});
</script>
</body>
</html>