-
Notifications
You must be signed in to change notification settings - Fork 58
/
index.html
254 lines (251 loc) · 10 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Conway's Game of Life</title>
<meta name="description" content="A JavaScript version of Conway's Game of Life, based on the Hashlife-algorithm.">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<link rel="stylesheet" href="life.css" type="text/css">
<script src="life.js"></script>
<script src="formats.js"></script>
<script src="draw.js"></script>
<script src="macrocell.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="toolbar" style="display: none;">
<div class="button" id="about_button">About</div>
<div class="menu" id="examples_menu">
<div id="pattern_button">Patterns</div>
</div>
<div id="randomize_button" class="button">Randomize</div>
<div id="export_button" class="button">Export</div>
<div id="import_button" class="button">Import</div>
<div class="button" id="settings_button">Settings</div>
<div class="button" id="clear_button">Clear</div>
<div class="button" style="display: none" id="superstep_button">Superstep</div>
<div class="button" id="step_button">Step</div>
<div class="button" id="rewind_button">Rewind</div>
<div class="button" id="run_button">Run</div>
<table id="controls">
<tr>
<td title="Normal speed"><div id="normalspeed_button">1</div></td>
<td title="Slower"><div id="slower_button">«</div></td>
<td title="Faster"><div id="faster_button">»</div></td>
</tr>
<tr>
<td title="Fit pattern"><div id="initial_pos_button">F</div></td>
<td title="Zoom in"><div id="zoomin_button">+</div></td>
<td title="Zoom out"><div id="zoomout_button">–</div></td>
</tr>
<tr class="not_on_small_screen">
<td title="Go north-west"><div id="nw_button">↖</div></td>
<td title="Go north"><div id="n_button">↑</div></td>
<td title="Go north-east"><div id="ne_button">↗</div></td>
</tr>
<tr class="not_on_small_screen">
<td title="Go east"><div id="e_button">←</div></td>
<td title="Go to 0, 0"><div id="middle_button">M</div></td>
<td title="Go west"><div id="w_button">→</div></td>
</tr>
<tr class="not_on_small_screen">
<td title="Go south-west"><div id="sw_button">↙</div></td>
<td title="Go south"><div id="s_button">↓</div></td>
<td title="Go south-east"><div id="se_button">↘</div></td>
</tr>
</table>
</div>
<div id="statusbar" style="display: none;">
<div id="label_zoom" title="Zoom"></div>
<div id="label_mou" title="Mouse Coordinates">0, 0</div>
<div id="label_fps" title="Frames per Second">0</div>
<div id="label_gen" title="Generation">0</div>
<div id="label_pop" title="Population">0</div>
<div id="label_step" title="Generation per Step">1</div>
<span id="pattern_name" class="link" title="Pattern infos"></span>
</div>
<div id="overlay">
<div id="about">
<h2>Conway's Game of Life in JavaScript</h2>
<div id="notice">
<h3 style="color: orange">Sorry, this applications needs JavaScript to work.</h3>
<div style="text-align: center">
<img src="pattern.gif" width="324" height="210" alt="Bi Gun">
</div>
<br>
<br>
</div>
This is an implementation of <a href="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life" target="_blank">Conway's Game of Life</a> or
more precisely, the super-fast <a href="https://en.wikipedia.org/wiki/Hashlife" target="_blank">Hashlife</a> algorithm,
written in JavaScript using the <code>canvas</code>-tag. It can simulate the largest known patterns, including the
<a href="?pattern=caterpillar" id="caterpillar_link" title="Click to load" class="link">Caterpillar</a> (7.6MB, 11m cells) and
<a href="?pattern=gemini" id="gemini_link" title="Click to load" class="link">Gemini</a> (1.6MB, 846k cells).
<br>
<br>
<div id="about_main" style="display: none">
If you encounter any bugs or have feedback, you can contact me at <a title="Click to show Email" href="?pattern=email">this email</a>.<br>
<br>
Click on the pattern name on the bottom left to get some informations about the current pattern.
<br>
<br>
<a href="examples/" target="_blank">List of all patterns</a> —
<a href="https://github.com/copy/life" target="_blank">Source code on Github</a> —
<a href="https://github.com/copy/life/issues" target="_blank">Report an issue</a>
<br>
<br>
<b>Controls:</b>
<pre>
Left mouse - Move around
Right mouse - Create / Delete cells
Mouse wheel - Zoom
Arrow keys, HJKL - Move around
+, - - Zoom
Space - One generation forward
Tab - Many generations forward
Enter - Run/Pause
Backspace - Rewind
] - Faster
[ - Slower
Escape - Close Popups
</pre>
</div>
<br>
<br>
<br>
<span class="button2" id="about_close" style="display: none">Ok</span>
</div>
<div id="randomize_dialog" style="display: none;">
<h2>Random Pattern</h2>
<div class="left">
Width
</div>
<div class="right">
<input type="number" min="1" id="randomize_width" style="width: 60px">
</div>
<br class="clear">
<br>
<div class="left">
Height
</div>
<div class="right">
<input type="number" min="1" id="randomize_height" style="width: 60px">
</div>
<br class="clear">
<br>
<div class="left">
Density
</div>
<div class="right">
<input type="number" id="randomize_density" min="0" max="1" step="0.1" style="width: 60px">
</div>
<br class="clear">
<br>
<br>
<br>
<span id="randomize_submit" class="button2">Randomize</span>
<span id="randomize_abort" class="button2">Abort</span>
</div>
<div id="import_dialog" style="display: none;">
<h2>Import Pattern</h2>
Supports RLE, Life 1.06, Plaintext
<br>
<br>
<textarea placeholder="Paste pattern file here" id="import_text"></textarea>
<br>
Or: <input type="file" id="import_file">
<br>
<br>
<div id="import_info"></div>
<br>
<br>
<br>
<span id="import_submit" class="button2">Import</span>
<span id="import_abort" class="button2">Abort</span>
</div>
<div id="alert" style="display: none;">
<div id="alert_text">
<h2 id="pattern_title"></h2>
<div id="pattern_description"></div>
<br>
<div id="pattern_urls"></div>
<br>
<div id="pattern_file_container">
Pattern file: <a target="_blank" id="pattern_file_link" href=""></a>
</div>
<div id="pattern_link_container">
Link to view online:
<a id="pattern_link" target="_blank" href=""></a>
</div>
</div>
<br>
<br>
<span class="button2" id="alert_close">Ok</span>
</div>
<div id="pattern_chooser" style="display: none;">
Source: <a href="http://www.conwaylife.com/wiki/Main_Page" target="_blank">www.conwaylife.com</a>. Thanks!
— <a href="examples/" target="_blank">List of all patterns</a>
<div id="pattern_list"></div>
<span class="button2" id="pattern_close">Close</span>
</div>
<div id="settings_dialog" style="display: none;">
<h2>Settings</h2>
<div class="left" id="select_rules">
Rule<br>
<small>
Or pick one:
<span class="link" data-rule="23/3">Conway</span>
<span class="link" data-rule="23/36">HighLife</span>
<span class="link" data-rule="125/36">2x2</span>
<span class="link" data-rule="1357/1357">Replicator</span>
</small>
</div>
<div class="right">
<input type="text" id="rule">
</div>
<br class="clear">
<br>
<div class="left">
Maximum Frames per Second
</div>
<div class="right">
<input type="number" min="1" id="max_fps" style="width: 60px">
</div>
<br class="clear">
<br>
<div class="left">
Generation step<br>
<small>Only powers of 2 (automatically rounded)</small>
</div>
<div class="right">
<input type="number" step="any" id="gen_step" style="width: 60px">
</div>
<br class="clear">
<br>
<div class="left">
Border width<br>
<small>0 .. 0.5</small>
</div>
<div class="right">
<input type="number" min="0" max="0.5" step="0.05" id="border_width" style="width: 60px">
</div>
<br>
<br>
<br>
<hr>
<br>
<br>
<span id="settings_submit" class="button2">Save</span>
<span id="settings_reset" class="button2">Reset</span>
<span id="settings_abort" class="button2">Abort</span>
</div>
<div id="loading_popup" style="display: none; font-size: 16px">
<div style="text-align: center">
<h2>Downloading pattern file</h2>
Please wait a second.<br><br>
<img src="pattern.gif" width="324" height="210" alt="Bi Gun">
</div>
</div>
</div>
<script>document.getElementById("overlay").style.display = "none"</script>
</body>
</html>