September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,38 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Mandelbrot set</title>
<script src="Mandelbrot.js" type="text/javascript"></script>
</head>
var mandelIter;
fetch("./mandelIter.wasm")
.then(res => {
if (res.ok) return res.arrayBuffer();
throw new Error('Unable to fetch WASM.');
})
.then(bytes => { return WebAssembly.compile(bytes); })
.then(module => { return WebAssembly.instantiate(module); })
.then(instance => { WebAssembly.instance = instance; draw(); })
<body onload="Mandelbrot()">
<h1>Mandelbrot set</h1>
function mandelbrot(canvas, xmin, xmax, ymin, ymax, iterations) {
// ...
var i = WebAssembly.instance.exports.mandelIter(x, y, iterations);
// ...
}
<form id="calcdata" onsubmit="javascript:Mandelbrot(); return false;">
<table>
<tr>
<td>xmin =</td>
<td><input name="xmin" type="text" size="10" value="-2"></td>
<td>xmax =</td>
<td><input name="xmax" type="text" size="10" value="1"></td>
</tr>
<tr>
<td>ymin =</td>
<td><input name="ymin" type="text" size="10" value="-1"></td>
<td>ymax =</td>
<td><input name="ymax" type="text" size="10" value="1"></td>
</tr>
</table>
<p>iterations =
<input name="iterations" type="text" size="10" value="1000"></p>
<p>
<input type="submit" value=" Calculate ">
<input type="reset" value=" Reset form ">
</p>
</form>
<canvas id="mandelimage" width="900" height="600">
This page needs a browser with canvas support.
</canvas>
</body>
</html>
function draw() {
// canvas initialization if necessary
// ...
mandelbrot(canvas, -2, 1, -1, 1, 1000);
// ...
}