add scale field in image settings, add extra button for drawing image right away#
[mandelbrot.git] / xulapp / chrome / mandelbrot / content / image-settings.js
index d9af9935a85f0c138dac817bce1d080206a462c4..a907f5a20bf677a820a4350f3c40b43f88d18a2d 100644 (file)
@@ -38,6 +38,8 @@
 var gColorPalette = [];
 
 function initSettings() {
+  recalcCoord('Cr', 'scale');
+  recalcCoord('Ci', 'scale');
 }
 
 function drawPreview() {
@@ -78,3 +80,16 @@ function drawPreview() {
   drawLine(0, [Cr_min, Cr_max, Ci_min, Ci_max],
               canvas, context, iterMax, algorithm);
 }
+
+function recalcCoord(coord, target) {
+  if (target == 'scale') {
+    document.getElementById(coord + '_scale').value =
+      parseFloat(document.getElementById(coord + '_max').value) -
+      parseFloat(document.getElementById(coord + '_min').value);
+  }
+  else if (target == 'max') {
+    document.getElementById('mandelbrot.last_image.' + coord + '_max').value =
+      parseFloat(document.getElementById(coord + '_min').value) +
+      parseFloat(document.getElementById(coord + '_scale').value);
+  }
+}
\ No newline at end of file