X-Git-Url: https://git-public.kairo.at/?p=mandelbrot.git;a=blobdiff_plain;f=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fimage-settings.js;fp=xulapp%2Fchrome%2Fmandelbrot%2Fcontent%2Fimage-settings.js;h=d9af9935a85f0c138dac817bce1d080206a462c4;hp=c00c19a148be5aeb2eb7f3fa09dcd3067bc1f093;hb=eceff1c913ed3ce42776db2b5b1cf69e44f0b921;hpb=6403d662069799da869e77b1a426a29ccbc85a44 diff --git a/xulapp/chrome/mandelbrot/content/image-settings.js b/xulapp/chrome/mandelbrot/content/image-settings.js index c00c19a..d9af993 100644 --- a/xulapp/chrome/mandelbrot/content/image-settings.js +++ b/xulapp/chrome/mandelbrot/content/image-settings.js @@ -35,5 +35,46 @@ * * ***** 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); +}