let canvas = document.getElementById("mbrotPreview");
let context = canvas.getContext("2d");
+ if (document.getElementById("imgWidth").value /
+ document.getElementById("imgHeight").value
+ < 80 / 50) {
+ canvas.height = 50;
+ canvas.width = canvas.height *
+ document.getElementById("imgWidth").value /
+ document.getElementById("imgHeight").value;
+ }
+ else {
+ canvas.width = 80;
+ canvas.height = canvas.width *
+ document.getElementById("imgHeight").value /
+ document.getElementById("imgWidth").value;
+ }
+
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) ||
}
function recalcCoord(coord, target) {
+ let othercoord = (coord == 'Ci') ? 'Cr' : 'Ci';
+ let owndim = (coord == 'Ci') ? 'height' : 'width';
+ let otherdim = (coord == 'Ci') ? 'width' : 'height';
if (target == 'scale') {
- document.getElementById(coord + '_scale').value =
+ var myscale =
parseFloat(document.getElementById(coord + '_max').value) -
parseFloat(document.getElementById(coord + '_min').value);
+ document.getElementById(coord + '_scale').value = roundCoord(myscale);
}
else if (target == 'max') {
- document.getElementById('mandelbrot.last_image.' + coord + '_max').value =
+ let mymax =
parseFloat(document.getElementById(coord + '_min').value) +
parseFloat(document.getElementById(coord + '_scale').value);
+ document.getElementById('mandelbrot.last_image.' + coord + '_max').value = roundCoord(mymax);
+ var myscale = document.getElementById(coord + '_scale').value;
}
+ if (document.getElementById('syncProp').checked) {
+ let otherscale = myscale *
+ document.getElementById('mandelbrot.image.' + otherdim).value /
+ document.getElementById('mandelbrot.image.' + owndim).value;
+ document.getElementById(othercoord + '_scale').value = roundCoord(otherscale);
+ let othermax =
+ parseFloat(document.getElementById(othercoord + '_min').value) +
+ parseFloat(document.getElementById(othercoord + '_scale').value);
+ document.getElementById('mandelbrot.last_image.' + othercoord + '_max').value = roundCoord(othermax);
+ }
+}
+
+function checkProportions() {
+ if (!document.getElementById('syncProp').checked) {
+ recalcCoord('Cr', 'scale');
+ }
+}
+
+function roundCoord(floatval) {
+ // We should round to 10 decimals here or so
+ return floatval;
}
\ No newline at end of file
type="string"/>
<preference id="mandelbrot.last_image.Ci_max" name="mandelbrot.last_image.Ci_max"
type="string"/>
+ <preference id="mandelbrot.syncProportions" name="mandelbrot.syncProportions"
+ type="bool"/>
</preferences>
<groupbox>
<hbox flex="1">
<label value="&img.width.label;" control="imgWidth"/>
<textbox id="imgWidth" size="4"
- preference="mandelbrot.image.width"/>
+ preference="mandelbrot.image.width"
+ onchange="recalcCoord('Ci', 'scale');"/>
</hbox>
<hbox flex="1">
<label value="&img.height.label;" control="imgHeight"/>
<textbox id="imgHeight" size="4"
- preference="mandelbrot.image.height"/>
+ preference="mandelbrot.image.height"
+ onchange="recalcCoord('Cr', 'scale');"/>
</hbox>
</groupbox>
</hbox>
<button id="previewButton" label="&previewDraw.label;" oncommand="drawPreview();"/>
</groupbox>
+
+ <groupbox>
+ <caption label="&options.title;"/>
+ <hbox flex="1">
+ <checkbox id="syncProp"
+ preference="mandelbrot.syncProportions"
+ onclick="checkProportions();"/>
+ <label value="&syncProp.label;" control="syncProp"/>
+ </hbox>
+ </groupbox>
</hbox>
</prefpane>
</prefwindow>