mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 22:41:30 +03:00
42 lines
947 B
HTML
42 lines
947 B
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>JavaScript mandelbrot set</title>
|
||
|
<style>pre {font-size:8pt;}</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>JavaScript generated mandelbrot set</h1>
|
||
|
<script>
|
||
|
function show_mandelbrot()
|
||
|
{
|
||
|
var gradation = " .,:;=|i+IhHOE#$ ";
|
||
|
document.writeln("<pre>");
|
||
|
for(i = -1.2; i <= 1.2; i += 0.04) {
|
||
|
for(r = -2; r <= 1; r += 0.02) {
|
||
|
var zr = r;
|
||
|
var zi = i;
|
||
|
var n = 0;
|
||
|
for(; n < 16; n++) {
|
||
|
var zr2 = zr * zr;
|
||
|
var zi2 = zi * zi;
|
||
|
if((zr2 + zi2) > 4) {
|
||
|
break;
|
||
|
}
|
||
|
zi = 2 * zr * zi + i;
|
||
|
zr = zr2 - zi2 + r;
|
||
|
}
|
||
|
document.write(gradation.charAt(n));
|
||
|
}
|
||
|
document.write("\n");
|
||
|
}
|
||
|
document.writeln("</pre>");
|
||
|
document.close();
|
||
|
}
|
||
|
show_mandelbrot();
|
||
|
</script>
|
||
|
<noscript>
|
||
|
JavaScript not enabled.
|
||
|
</noscript>
|
||
|
</body>
|
||
|
</html>
|