From: Robert Kaiser Date: Mon, 27 Oct 2008 17:11:56 +0000 (+0100) Subject: extend image settings with coordinates and preview X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=eceff1c913ed3ce42776db2b5b1cf69e44f0b921;p=mandelbrot.git extend image settings with coordinates and preview --- 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); +} diff --git a/xulapp/chrome/mandelbrot/content/image-settings.xul b/xulapp/chrome/mandelbrot/content/image-settings.xul index efe8288..04da656 100644 --- a/xulapp/chrome/mandelbrot/content/image-settings.xul +++ b/xulapp/chrome/mandelbrot/content/image-settings.xul @@ -44,6 +44,7 @@ + + + + - + + + - + - + + + + + + + + + + + + + + + +