-
Notifications
You must be signed in to change notification settings - Fork 0
/
mandelbrot.html
executable file
·47 lines (42 loc) · 1.7 KB
/
mandelbrot.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Визуализация множества Мандельброта</title>
<meta name="viewport" content="width=500">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
<canvas id="main-canvas" width="500" height="500"></canvas><br>
Масштаб: <input type="text" id="zoom" value="1" oninput="updateZoom(this)"/>
<button id="koch-inc" type="button">-</button>
<button id="koch-dec" type="button">+</button><br>
<a href="https://brigaccess.github.io/fractaldemo/">Демонстрация алгоритмов</a>
<script src="mandelbrot.js"></script>
<script>
// Antialiasing fix
document.getElementById("main-canvas").getContext('2d').translate(0.5, 0.5);
var canvas = document.getElementById("main-canvas");
var mand = new MandelbrotSet(canvas);
var zoomInp = document.getElementById("zoom");
window.updateZoom = function(inp) {
mand.updateZoom(parseFloat(inp.value));
}
document.getElementById("koch-dec").onclick = function() {
let val = parseFloat(zoomInp.value);
if (Number.isFinite(val)) {
zoomInp.value = val / 2;
}
updateZoom(zoomInp);
}
document.getElementById("koch-inc").onclick = function() {
let val = parseFloat(zoomInp.value);
if (Number.isFinite(val)) {
zoomInp.value = val * 2;
}
updateZoom(zoomInp);
}
</script>
</body>
</html>