-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmandelbrot.html
48 lines (45 loc) · 1005 Bytes
/
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
48
<html>
<head>
<title> Mandelbrot Drawing </title>
</head>
<body style="background: black">
<canvas id="canvas" width=800 height=800></canvas>
<script src="mandelbrot.js"> </script>
<script>
canvas = document.getElementById("canvas");
ctx = canvas.getContext("2d");
//data = mb_gen_data(3.0, 800, 800, 0.0, 0.0, 800, 0.0);
//draw_mandelbrot_image(data, ctx);
var rot = 0.0;
var scale = 1.0;
var counter = 0;
var interval = 175;
var counter_max = 120;
var drot = Math.PI/counter_max;
var dscale = 2.0/counter_max;
function mb_animate() {
or = Math.cos(rot);
oi = Math.sin(rot);
data = mb_gen_data(1.0, 800, 800, or, oi, 300, rot);
draw_mandelbrot_image(data, ctx);
counter++;
counter = counter%counter_max;
if(counter == 0) {
scale = 1.0;
rot = 0.0;
dscale *= -1;
drot *= -1;
} else if(counter == counter_max/2) {
scale = 5.0;
rot = 0.0;
dscale = -1;
drot *= -1;
} else {
scale += dscale;
rot += drot;
}
}
window.setInterval(mb_animate, interval);
</script>
</body>
</html>