- if (canvas.getContext) {
- let context = canvas.getContext("2d");
-
- // example:
- // context.fillStyle = "rgb(200,0,0)";
- // context.fillRect (10, 10, 55, 50); // x, y, width, height
- //
- // context.fillStyle = "rgba(0, 0, 200, 0.5)";
- // context.fillRect (30, 30, 55, 50);
-
- let Cr_min = -2.0;
- let Cr_max = 1.0;
+ let context = canvas.getContext("2d");
+
+ document.getElementById("statusLabel").value =
+ document.getElementById("mbrotBundle").getString("statusDrawing");
+
+ let Cr_min = -2.0;
+ let Cr_max = 1.0;
+ try {
+ Cr_min = parseFloat(gPref.getCharPref("mandelbrot.last_image.Cr_min"));
+ Cr_max = parseFloat(gPref.getCharPref("mandelbrot.last_image.Cr_max"));
+ }
+ catch (e) { }
+ if ((Cr_min < -2) || (Cr_min > 2) ||
+ (Cr_max < -2) || (Cr_max > 2) || (Cr_min >= Cr_max)) {
+ Cr_min = -2.0; Cr_max = 1.0;
+ }
+ gPref.setCharPref("mandelbrot.last_image.Cr_min", Cr_min);
+ gPref.setCharPref("mandelbrot.last_image.Cr_max", Cr_max);
+
+ let Ci_min = -1.5;
+ let Ci_max = 1.5;
+ try {
+ Ci_min = parseFloat(gPref.getCharPref("mandelbrot.last_image.Ci_min"));
+ Ci_max = parseFloat(gPref.getCharPref("mandelbrot.last_image.Ci_max"));
+ }
+ catch (e) { }
+ if ((Ci_min < -2) || (Ci_min > 2) ||
+ (Ci_max < -2) || (Ci_max > 2) || (Ci_min >= Ci_max)) {
+ Ci_min = -2.0; Ci_max = 1.0;
+ }
+ gPref.setCharPref("mandelbrot.last_image.Ci_min", Ci_min);
+ gPref.setCharPref("mandelbrot.last_image.Ci_max", Ci_max);
+
+ let iterMax = gPref.getIntPref("mandelbrot.iteration_max");
+ let algorithm = gPref.getCharPref("mandelbrot.use_algorithm");
+
+ let iWidth = 0;
+ try {
+ iWidth = gPref.getIntPref("mandelbrot.image.width");
+ }
+ catch (e) { }
+ if ((iWidth < 10) || (iWidth > 5000)) {
+ iWidth = 300;
+ gPref.setIntPref("mandelbrot.image.width", iWidth);
+ }
+ let iHeight = 0;
+ try {
+ iHeight = gPref.getIntPref("mandelbrot.image.height");
+ }
+ catch (e) { }
+ if ((iHeight < 10) || (iHeight > 5000)) {
+ iHeight = 300;
+ gPref.setIntPref("mandelbrot.image.height", iHeight);
+ }
+
+ canvas.width = iWidth;
+ canvas.height = iHeight;
+
+ context.fillStyle = "rgba(255, 255, 255, 127)";
+ context.fillRect(0, 0, canvas.width, canvas.height);
+
+ gStartTime = new Date();
+
+ drawLine(0, [Cr_min, Cr_max, Ci_min, Ci_max],
+ canvas, context, iterMax, algorithm);
+}
+
+function drawLine(line, dimensions, canvas, context, iterMax, algorithm) {
+ let Cr_min = dimensions[0];
+ let Cr_max = dimensions[1];