test/js: Include mandelbrot example

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2020-05-22 19:53:20 +01:00
parent daed553a06
commit 1223cf0786
No known key found for this signature in database
GPG Key ID: C30DF439F2987D74
2 changed files with 32 additions and 0 deletions

View File

@ -104,6 +104,7 @@
<li><a href="assorted-log-doc-write.html">console.log and document.write</a></li>
<li><a href="wikipedia-lcm.html">Example from wikipedia</a></li>
<li><a href="verify-instanceofness.html">Check instanceof behaviour</a></li>
<li><a href="mandelbrot.html">Canvas/ImageData Mandelbrot ploter</a></li>
</ul>
</body>

31
test/js/mandelbrot.html Normal file
View File

@ -0,0 +1,31 @@
<html>
<head>
<title>JS Mandelbrot</title>
<script src="https://nerget.com/mandelbrot.js"></script>
<script>
var drawn = false;
var dimension = 2;
var cx = -dimension / 2 + 0.5;
var cy = -dimension / 2;
function log(msg) {
document.getElementById("log").innerHTML += msg + "<br/>";
}
function draw() {
var forceSlowPath = document.getElementById('forceSlowPath').checked;
drawMandelbrot(document.getElementById('canvas').getContext('2d'), 200, 200,
cx + dimension / 2, cy + dimension / 2, dimension, 500, forceSlowPath);
drawn = true;
}
</script>
</head>
<body>
<canvas id="canvas" width="200" height="200" style="border: 1px solid black;"></canvas>
<br />
<input id="forceSlowPath" type="checkbox">Use slow path.</input> <br />
<a href="javascript:draw()">Start</a>
<div id="log"></div>
</body>
</html>