*
* ***** END LICENSE BLOCK ***** */
+var gColorPalette = [];
+
function initSettings() {
}
+
+function drawPreview() {
+ let canvas = document.getElementById("mbrotPreview");
+ let context = canvas.getContext("2d");
+
+ let Cr_min = parseFloat(document.getElementById("Cr_min").value);
+ let Cr_max = parseFloat(document.getElementById("Cr_max").value);
+ 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;
+ }
+
+ let Ci_min = parseFloat(document.getElementById("Ci_min").value);
+ let Ci_max = parseFloat(document.getElementById("Ci_max").value);
+ 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;
+ }
+
+ let iterMax = gPref.getIntPref("mandelbrot.iteration_max");
+ let algorithm = gPref.getCharPref("mandelbrot.use_algorithm");
+
+ context.fillStyle = "rgba(255, 255, 255, 127)";
+ context.fillRect(0, 0, canvas.width, canvas.height);
+
+ try {
+ var currentPalette = gPref.getCharPref("mandelbrot.color_palette");
+ }
+ catch(e) {
+ var currentPalette = '';
+ }
+ if (!currentPalette.length) {
+ currentPalette = 'kairo';
+ }
+ gColorPalette = getColorPalette(currentPalette);
+
+ drawLine(0, [Cr_min, Cr_max, Ci_min, Ci_max],
+ canvas, context, iterMax, algorithm);
+}
<prefwindow id="imgSettingsDlg"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:html="http://www.w3.org/1999/xhtml"
title="&imageSettings.title;"
dlgbuttons="accept,cancel"
ondialogaccept="callDrawImage();"
type="int"/>
<preference id="mandelbrot.image.height" name="mandelbrot.image.height"
type="int"/>
+ <preference id="mandelbrot.last_image.Cr_min" name="mandelbrot.last_image.Cr_min"
+ type="string"/>
+ <preference id="mandelbrot.last_image.Cr_max" name="mandelbrot.last_image.Cr_max"
+ type="string"/>
+ <preference id="mandelbrot.last_image.Ci_min" name="mandelbrot.last_image.Ci_min"
+ type="string"/>
+ <preference id="mandelbrot.last_image.Ci_max" name="mandelbrot.last_image.Ci_max"
+ type="string"/>
</preferences>
- <groupbox label="&img.size.title;">
+ <groupbox>
+ <caption label="&coord.title;"/>
+ <description value="&coord.real.label;"/>
<hbox flex="1">
- <label value="&img.width.label;" control="imgWidth"/>
- <textbox id="imgWidth" size="4" preference="mandelbrot.image.width"/>
+ <label value="&coord.min.label;" control="Cr_min"/>
+ <textbox id="Cr_min" size="10"
+ preference="mandelbrot.last_image.Cr_min"/>
+ <label value="&coord.max.label;" control="Cr_max"/>
+ <textbox id="Cr_max" size="10"
+ preference="mandelbrot.last_image.Cr_max"/>
</hbox>
+ <description value="&coord.imag.label;"/>
<hbox flex="1">
- <label value="&img.height.label;" control="imgHeight"/>
- <textbox id="imgHeight" size="4" preference="mandelbrot.image.heigth"/>
+ <label value="&coord.min.label;" control="Ci_min"/>
+ <textbox id="Ci_min" size="10"
+ preference="mandelbrot.last_image.Ci_min"/>
+ <label value="&coord.max.label;" control="Ci_max"/>
+ <textbox id="Ci_max" size="10"
+ preference="mandelbrot.last_image.Ci_max"/>
</hbox>
</groupbox>
+
+ <hbox flex="1">
+ <groupbox>
+ <caption label="&img.size.title;"/>
+ <hbox flex="1">
+ <label value="&img.width.label;" control="imgWidth"/>
+ <textbox id="imgWidth" size="4"
+ preference="mandelbrot.image.width"/>
+ </hbox>
+ <hbox flex="1">
+ <label value="&img.height.label;" control="imgHeight"/>
+ <textbox id="imgHeight" size="4"
+ preference="mandelbrot.image.height"/>
+ </hbox>
+ </groupbox>
+
+ <groupbox>
+ <caption label="&preview.title;"/>
+ <hbox flex="1" pack="center" align="center">
+ <html:canvas id="mbrotPreview" width="50" height="50"></html:canvas>
+ </hbox>
+ <button id="previewButton" label="&previewDraw.label;" oncommand="drawPreview();"/>
+ </groupbox>
+ </hbox>
</prefpane>
</prefwindow>
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");
- context.fillStyle = "rgb(255, 255, 255)";
+ 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, canvas, context, iterMax, algorithm);
+ drawLine(0, [Cr_min, Cr_max, Ci_min, Ci_max],
+ canvas, context, iterMax, algorithm);
}
-function drawLine(line, canvas, context, iterMax, algorithm) {
- let Cr_min = -2.0;
- let Cr_max = 1.0;
- try {
- Cr_min = gPref.getCharPref("mandelbrot.last_image.Cr_min");
- Cr_max = gPref.getCharPref("mandelbrot.last_image.Cr_max");
- }
- catch (e) { }
+function drawLine(line, dimensions, canvas, context, iterMax, algorithm) {
+ let Cr_min = dimensions[0];
+ let Cr_max = dimensions[1];
let Cr_scale = Cr_max - Cr_min;
- let Ci_min = -1.5;
- let Ci_max = 1.5;
- try {
- Cr_min = gPref.getCharPref("mandelbrot.last_image.Ci_min");
- Cr_max = gPref.getCharPref("mandelbrot.last_image.Ci_max");
- }
- catch (e) { }
+ let Ci_min = dimensions[2];
+ let Ci_max = dimensions[3];
let Ci_scale = Ci_max - Ci_min;
let pixels = [];
context.putImageData({width: canvas.width, height: pixels.length/4/canvas.width, data: pixels}, 0, line);
if (img_y < canvas.height)
- setTimeout(drawLine, 0, img_y, canvas, context, iterMax, algorithm);
+ setTimeout(drawLine, 0, img_y, dimensions, canvas, context, iterMax, algorithm);
else
EndCalc();
}
<!ENTITY imageSettings.title "Image Settings">
<!ENTITY DrawImageButton.label "Draw Image">
+<!ENTITY coord.title "Coordinates">
+<!ENTITY coord.real.label "Real">
+<!ENTITY coord.imag.label "Imaginary">
+<!ENTITY coord.min.label "From">
+<!ENTITY coord.max.label "To">
+
<!ENTITY img.size.title "Image Size">
<!ENTITY img.width.label "Width">
<!ENTITY img.height.label "Height">
+
+<!ENTITY preview.title "Preview">
+<!ENTITY previewDraw.label "Preview">