X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fimage-settings.js;h=a907f5a20bf677a820a4350f3c40b43f88d18a2d;hp=c00c19a148be5aeb2eb7f3fa09dcd3067bc1f093;hb=7727ce46183a6fb4adaaf0e5b63cd06a6034a2a8;hpb=6403d662069799da869e77b1a426a29ccbc85a44 diff --git a/xulapp/chrome/mandelbrot/content/image-settings.js b/xulapp/chrome/mandelbrot/content/image-settings.js index c00c19a..a907f5a 100644 --- a/xulapp/chrome/mandelbrot/content/image-settings.js +++ b/xulapp/chrome/mandelbrot/content/image-settings.js @@ -35,5 +35,61 @@ * * ***** END LICENSE BLOCK ***** */ +var gColorPalette = []; + function initSettings() { + recalcCoord('Cr', 'scale'); + recalcCoord('Ci', 'scale'); +} + +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); } + +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