-function adjustCoordsAndDraw(aC_min, aC_max) {
- 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);
+function getAdjustPref(prefname) {
+ let value;
+ switch (prefname) {
+ case "image.width":
+ case "image.height":
+ value = 0;
+ try {
+ value = gPref.getIntPref("mandelbrot." + prefname);
+ }
+ catch (e) { }
+ if ((value < 10) || (value > 5000)) {
+ value = 300;
+ gPref.setIntPref("mandelbrot." + prefname, value);
+ }
+ return value;
+ case "last_image.Cr_*":
+ 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 < -3) || (Cr_min > 2) ||
+ (Cr_max < -3) || (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);
+ return {Cr_min: Cr_min, Cr_max: Cr_max};
+ case "last_image.Ci_*":
+ 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.5) || (Ci_min > 2.5) ||
+ (Ci_max < -2.5) || (Ci_max > 2.5) || (Ci_min >= Ci_max)) {
+ Ci_min = -1.5; Ci_max = 1.5;
+ }
+ gPref.setCharPref("mandelbrot.last_image.Ci_min", Ci_min);
+ gPref.setCharPref("mandelbrot.last_image.Ci_max", Ci_max);
+ return {Ci_min: Ci_min, Ci_max: Ci_max};
+ case "iteration_max":
+ value = 500;
+ try {
+ value = gPref.getIntPref("mandelbrot." + prefname);
+ }
+ catch (e) {
+ setIter(value);
+ }
+ if (value < 10 || value > 10000) {
+ value = 500;
+ setIter(value);
+ }
+ return value;
+ case "use_algorithm":
+ value = "numeric";
+ try {
+ value = gPref.getCharPref("mandelbrot." + prefname);
+ }
+ catch (e) {
+ setAlgorithm(value);
+ }
+ return value;
+ case "color_palette":
+ value = "kairo";
+ try {
+ value = gPref.getCharPref("mandelbrot." + prefname);
+ }
+ catch(e) {
+ setPalette(value);
+ }
+ return value;
+ case "syncProportions":
+ value = true;
+ try {
+ value = gPref.getBoolPref("mandelbrot." + prefname);
+ }
+ catch(e) {
+ gPref.setBoolPref("mandelbrot." + prefname, value);
+ }
+ return value;
+ default:
+ return false;