- Notifications
You must be signed in to change notification settings - Fork63
/
Copy pathindex.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>
<metahttp-equiv="Content-Type"content="text/html; charset=utf-8">
<title>Conway's Game of Life</title>
<metaname="description"content="A JavaScript version of Conway's Game of Life, based on the Hashlife-algorithm.">
<metaname="viewport"content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<linkrel="stylesheet"href="life.css"type="text/css">
<scriptsrc="life.js"></script>
<scriptsrc="formats.js"></script>
<scriptsrc="draw.js"></script>
<scriptsrc="macrocell.js"></script>
<scriptsrc="main.js"></script>
</head>
<body>
<divid="toolbar"style="display: none;">
<divclass="button"id="about_button">About</div>
<divclass="menu"id="examples_menu">
<divid="pattern_button">Patterns</div>
</div>
<divid="randomize_button"class="button">Randomize</div>
<divid="export_button"class="button">Export</div>
<divid="import_button"class="button">Import</div>
<divclass="button"id="settings_button">Settings</div>
<divclass="button"id="clear_button">Clear</div>
<divclass="button"style="display: none"id="superstep_button">Superstep</div>
<divclass="button"id="step_button">Step</div>
<divclass="button"id="rewind_button">Rewind</div>
<divclass="button"id="run_button">Run</div>
<tableid="controls">
<tr>
<tdtitle="Normal speed"><divid="normalspeed_button">1</div></td>
<tdtitle="Slower"><divid="slower_button">«</div></td>
<tdtitle="Faster"><divid="faster_button">»</div></td>
</tr>
<tr>
<tdtitle="Fit pattern"><divid="initial_pos_button">F</div></td>
<tdtitle="Zoom in"><divid="zoomin_button">+</div></td>
<tdtitle="Zoom out"><divid="zoomout_button">–</div></td>
</tr>
<trclass="not_on_small_screen">
<tdtitle="Go north-west"><divid="nw_button">↖</div></td>
<tdtitle="Go north"><divid="n_button">↑</div></td>
<tdtitle="Go north-east"><divid="ne_button">↗</div></td>
</tr>
<trclass="not_on_small_screen">
<tdtitle="Go east"><divid="e_button">←</div></td>
<tdtitle="Go to 0, 0"><divid="middle_button">M</div></td>
<tdtitle="Go west"><divid="w_button">→</div></td>
</tr>
<trclass="not_on_small_screen">
<tdtitle="Go south-west"><divid="sw_button">↙</div></td>
<tdtitle="Go south"><divid="s_button">↓</div></td>
<tdtitle="Go south-east"><divid="se_button">↘</div></td>
</tr>
</table>
</div>
<divid="statusbar"style="display: none;">
<divid="label_zoom"title="Zoom"></div>
<divid="label_mou"title="Mouse Coordinates">0, 0</div>
<divid="label_fps"title="Frames per Second">0</div>
<divid="label_gen"title="Generation">0</div>
<divid="label_pop"title="Population">0</div>
<divid="label_step"title="Generation per Step">1</div>
<spanid="pattern_name"class="link"title="Pattern infos"></span>
</div>
<divid="overlay">
<divid="about">
<h2>Conway's Game of Life in JavaScript</h2>
<divid="notice">
<h3style="color: orange">Sorry, this applications needs JavaScript to work.</h3>
<divstyle="text-align: center">
<imgsrc="pattern.gif"width="324"height="210"alt="Bi Gun">
</div>
<br>
<br>
</div>
This is an implementation of<ahref="http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life"target="_blank">Conway's Game of Life</a> or
more precisely, the super-fast<ahref="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
<ahref="?pattern=caterpillar"id="caterpillar_link"title="Click to load"class="link">Caterpillar</a> (7.6MB, 11m cells) and
<ahref="?pattern=gemini"id="gemini_link"title="Click to load"class="link">Gemini</a> (1.6MB, 846k cells).
<br>
<br>
<divid="about_main"style="display: none">
If you encounter any bugs or have feedback, you can contact me at<atitle="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>
<ahref="examples/"target="_blank">List of all patterns</a> —
<ahref="https://github.com/copy/life"target="_blank">Source code on Github</a> —
<ahref="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>
<spanclass="button2"id="about_close"style="display: none">Ok</span>
</div>
<divid="randomize_dialog"style="display: none;">
<h2>Random Pattern</h2>
<divclass="left">
Width
</div>
<divclass="right">
<inputtype="number"min="1"id="randomize_width"style="width: 60px">
</div>
<brclass="clear">
<br>
<divclass="left">
Height
</div>
<divclass="right">
<inputtype="number"min="1"id="randomize_height"style="width: 60px">
</div>
<brclass="clear">
<br>
<divclass="left">
Density
</div>
<divclass="right">
<inputtype="number"id="randomize_density"min="0"max="1"step="0.1"style="width: 60px">
</div>
<brclass="clear">
<br>
<br>
<br>
<spanid="randomize_submit"class="button2">Randomize</span>
<spanid="randomize_abort"class="button2">Abort</span>
</div>
<divid="import_dialog"style="display: none;">
<h2>Import Pattern</h2>
Supports RLE, Life 1.06, Plaintext
<br>
<br>
<textareaplaceholder="Paste pattern file here"id="import_text"></textarea>
<br>
Or:<inputtype="file"id="import_file">
<br>
<br>
<divid="import_info"></div>
<br>
<br>
<br>
<spanid="import_submit"class="button2">Import</span>
<spanid="import_abort"class="button2">Abort</span>
</div>
<divid="alert"style="display: none;">
<divid="alert_text">
<h2id="pattern_title"></h2>
<divid="pattern_description"></div>
<br>
<divid="pattern_urls"></div>
<br>
<divid="pattern_file_container">
Pattern file:<atarget="_blank"id="pattern_file_link"href=""></a>
</div>
<divid="pattern_link_container">
Link to view online:
<aid="pattern_link"target="_blank"href=""></a>
</div>
</div>
<br>
<br>
<spanclass="button2"id="alert_close">Ok</span>
</div>
<divid="pattern_chooser"style="display: none;">
Source:<ahref="http://www.conwaylife.com/wiki/Main_Page"target="_blank">www.conwaylife.com</a>. Thanks!
—<ahref="examples/"target="_blank">List of all patterns</a>
<divid="pattern_list"></div>
<spanclass="button2"id="pattern_close">Close</span>
</div>
<divid="settings_dialog"style="display: none;">
<h2>Settings</h2>
<divclass="left"id="select_rules">
Rule<br>
<small>
Or pick one:
<spanclass="link"data-rule="23/3">Conway</span>
<spanclass="link"data-rule="23/36">HighLife</span>
<spanclass="link"data-rule="125/36">2x2</span>
<spanclass="link"data-rule="1357/1357">Replicator</span>
</small>
</div>
<divclass="right">
<inputtype="text"id="rule">
</div>
<brclass="clear">
<br>
<divclass="left">
Maximum Frames per Second
</div>
<divclass="right">
<inputtype="number"min="1"id="max_fps"style="width: 60px">
</div>
<brclass="clear">
<br>
<divclass="left">
Generation step<br>
<small>Only powers of 2 (automatically rounded)</small>
</div>
<divclass="right">
<inputtype="number"step="any"id="gen_step"style="width: 60px">
</div>
<brclass="clear">
<br>
<divclass="left">
Border width<br>
<small>0 .. 0.5</small>
</div>
<divclass="right">
<inputtype="number"min="0"max="0.5"step="0.05"id="border_width"style="width: 60px">
</div>
<br>
<br>
<br>
<hr>
<br>
<br>
<spanid="settings_submit"class="button2">Save</span>
<spanid="settings_reset"class="button2">Reset</span>
<spanid="settings_abort"class="button2">Abort</span>
</div>
<divid="loading_popup"style="display: none; font-size: 16px">
<divstyle="text-align: center">
<h2>Downloading pattern file</h2>
Please wait a second.<br><br>
<imgsrc="pattern.gif"width="324"height="210"alt="Bi Gun">
</div>
</div>
</div>
<script>document.getElementById("overlay").style.display="none"</script>
</body>
</html>