<!DOCTYPE html>
<html>
<head>
<?php session_start();?>
<?php include 'includes/meta.php'; ?>
</head>


<body>
	<?php include 'includes/header.php'; ?>
	<canvas id="mandelbrot" width="500" height="500">walou</canvas>
	BIS
	<script type="text/javascript">
		window.onload = function() {
			var canvas = document.getElementById('mandelbrot');
			if (!canvas) {
				alert("Impossible de récupérer le canvas");
				return;
			}

			var context = canvas.getContext('2d');
			if (!context) {
				alert("Impossible de récupérer le context du canvas");
				return;
			}
			context.fillStyle = "#ff0000";

			var x1 = -2.1, x2 = 0.6, y1 = -1.2, y2 = 1.2, zoom = 100, iterations_max = 50, image_x = (x2 - x1)
					* zoom, image_y = (y2 - y1) * zoom;
			canvas.width = image_x;
			canvas.heigth = image_y;

			for (x = 0; x < image_x; x++) {
				for (y = 0; y < image_y; y++) {
					c_r = x / zoom + x1;
					c_i = y / zoom + y1;
					z_r = 0;
					z_i = 0;
					i = 0;
					do {
						var tmp = z_r;
						z_r = z_r * z_r - z_i * z_i + c_r;
						z_i = 2 * tmp * z_i + c_i;
						i++;
					} while (z_r * z_r + z_i * z_i < 4 && i < iterations_max);
					if (i == iterations_max) {
						context.fillStyle = "#FFFFFF";
						context.fillRect(x, y, 1, 1);
					}else{
						context.fillStyle = "rgb(0, 0, "+255-(i*255/iterations_max)+")";
						context.fillRect(x,y,1,1);
					}
					alert('done');
				}
			}
		}
	</script>