From: Robert Kaiser Date: Sat, 1 Aug 2009 22:59:45 +0000 (+0200) Subject: Convert rainbow palettes from VB to JS code and make them available X-Git-Url: https://git-public.kairo.at/?a=commitdiff_plain;h=72eff46498152f4affe14d5cd9489e19b35156e2;p=mandelbrot.git Convert rainbow palettes from VB to JS code and make them available --- diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.js b/xulapp/chrome/mandelbrot/content/mandelbrot.js index 28b443c..1ead31e 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.js +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.js @@ -258,10 +258,62 @@ function getColorPalette(palName) { } palette[1024] = [0, 0, 0, 255]; break; + case 'rainbow-squared1': + for (let i = 0; i < 34; i++) { + let cc = Math.floor(i * 255 / 33); + palette[i] = [cc, 0, 0, 255]; + } + for (let i = 0; i < 137; i++) { + let cc = Math.floor(i * 255 / 136); + palette[34 + i] = [255, cc, 0, 255]; + } + for (let i = 0; i < 307; i++) { + let cc = Math.floor(i * 255 / 306); + palette[171 + i] = [255 - cc, 255, cc, 255]; + } + for (let i = 0; i < 546; i++) { + let cc = Math.floor(i * 255 / 545); + palette[478 + i] = [cc, 255 - cc, 255, 255]; + } + palette[1024] = [0, 0, 0, 255]; + break; + case 'rainbow-linear2': + for (let i = 0; i < 205; i++) { + let cc = Math.floor(i * 255 / 204); + palette[i] = [255, cc, 0, 255]; + palette[204 + i] = [255 - cc, 255, 0, 255]; + palette[409 + i] = [0, 255, cc, 255]; + palette[614 + i] = [0, 255 - cc, 255, 255]; + palette[819 + i] = [cc, 0, 255, 255]; + } + palette[1024] = [0, 0, 0, 255]; + break; + case 'rainbow-squared2': + for (let i = 0; i < 19; i++) { + let cc = Math.floor(i * 255 / 18); + palette[i] = [255, cc, 0, 255]; + } + for (let i = 0; i < 74; i++) { + let cc = Math.floor(i * 255 / 73); + palette[19 + i] = [255 - cc, 255, 0, 255]; + } + for (let i = 0; i < 168; i++) { + let cc = Math.floor(i * 255 / 167); + palette[93 + i] = [0, 255, cc, 255]; + } + for (let i = 0; i < 298; i++) { + let cc = Math.floor(i * 255 / 297); + palette[261 + i] = [0, 255 - cc, 255, 255]; + } + for (let i = 0; i < 465; i++) { + let cc = Math.floor(i * 255 / 464); + palette[559 + i] = [cc, 0, 255, 255]; + } + palette[1024] = [0, 0, 0, 255]; + break; } -/* -Select Case palnr -Case 1 'Standard-Palette (QB-Colors) + /* + 'Standard-Palette (QB-Colors) For i = 0 To 1024 xx = CInt(i * 500 / 1024 + 2) If xx <= 15 Then clr = xx @@ -269,54 +321,7 @@ Case 1 'Standard-Palette (QB-Colors) If xx >= 500 Then clr = 0 palette(i) = QBColor(clr) Next -Case 3 'Regenbogen-Palette 1 (qu.) - For i = 0 To 33 - clr = CInt(i * 255 / 33) - palette(i) = RGB(clr, 0, 0) - Next - For i = 0 To 136 - clr = CInt(i * 255 / 136) - palette(34 + i) = RGB(255, clr, 0) - Next - For i = 0 To 306 - clr = CInt(i * 255 / 306) - palette(171 + i) = RGB(255 - clr, 255, clr) - Next - For i = 0 To 545 - clr = CInt(i * 255 / 545) - palette(478 + i) = RGB(clr, 255 - clr, 255) - Next -Case 4 'Regenbogen-Palette 2 (linear) - For i = 0 To 204 - clr = CInt(i * 255 / 204) - palette(i) = RGB(255, clr, 0) - palette(204 + i) = RGB(255 - clr, 255, 0) - palette(409 + i) = RGB(0, 255, clr) - palette(614 + i) = RGB(0, 255 - clr, 255) - palette(819 + i) = RGB(clr, 0, 255) - Next -Case 5 'Regenbogen-Palette 2 (qu.) - For i = 0 To 18 - clr = CInt(i * 255 / 18) - palette(i) = RGB(255, clr, 0) - Next - For i = 0 To 73 - clr = CInt(i * 255 / 73) - palette(20 + i) = RGB(255 - clr, 255, 0) - Next - For i = 0 To 167 - clr = CInt(i * 255 / 167) - palette(93 + i) = RGB(0, 255, clr) - Next - For i = 0 To 297 - clr = CInt(i * 255 / 297) - palette(261 + i) = RGB(0, 255 - clr, 255) - Next - For i = 0 To 464 - clr = CInt(i * 255 / 464) - palette(559 + i) = RGB(clr, 0, 255) - Next -*/ + */ return palette; } diff --git a/xulapp/chrome/mandelbrot/content/mandelbrot.xul b/xulapp/chrome/mandelbrot/content/mandelbrot.xul index 596a4e7..5719872 100644 --- a/xulapp/chrome/mandelbrot/content/mandelbrot.xul +++ b/xulapp/chrome/mandelbrot/content/mandelbrot.xul @@ -96,6 +96,10 @@ + + + + diff --git a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd index 738b7fb..1a9ff9f 100644 --- a/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd +++ b/xulapp/chrome/mandelbrot/locales/en-US/mandelbrot.dtd @@ -55,6 +55,10 @@ + + + +