-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.htm
44 lines (36 loc) · 1.27 KB
/
index.htm
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
<html lang=en>
<head>
<style>
body { text-align: center; margin: 100px; font-family: monospace; font-size: 14px; }
canvas { margin: 40px; border: 1px solid black; }
</style>
</head>
<body>
<script src='canvas.js'></script>
<script src='color.js'></script>
<script src='math.js'></script>
<h4>
Drag to move<br/>
Right/left click to zoom<br/>
Click, hold, and release the Mandelbrot (left) to set the C value in the rational map z => z<sup>2</sup> + C used by the Julia (right)<br/>
<span></span><br/>
</h4>
<hr />
<canvas id=mandl width=600 height=600></canvas>
<canvas id=julia width=600 height=600></canvas>
<script>
////////////////////////////////////////////////////////////////////////////////
'use strict'
const parseComplex = z => `${z[0].toFixed(4)} ${z[1] < 0 ? '-' : '+'} ${Math.abs(z[1]).toFixed(4)}i`
const mandl = Canvas('mandl', math.mandelbrot, { a: -2.2, b: -1.5, zoom: 1/200, i: 99 })
const julia = Canvas('julia', math.sampleJulia, { a: -1.9, b: -2.0, zoom: 1/160, i: 99 })
mandl.onClick(e => {
const C = mandl.pixelLocation(e.offsetX, e.offsetY)
document.title = parseComplex(C)
julia.setGenerator(math.getJulia(C))
})
document.title = performance.now() | 0
////////////////////////////////////////////////////////////////////////////////
</script>
</body>
</html>