Mercurial > hg > digilib-old
changeset 1066:555f6f0d6be5
prepare for making rgb indicator an independent widget
author | hertzhaft |
---|---|
date | Mon, 02 Apr 2012 08:19:21 +0200 |
parents | 897f0560af46 |
children | a45894a81e40 |
files | webapp/src/main/webapp/jquery/jquery.digilib.sliders.js |
diffstat | 1 files changed, 45 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js Mon Apr 02 00:00:47 2012 +0200 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.sliders.js Mon Apr 02 08:19:21 2012 +0200 @@ -105,6 +105,7 @@ var indicators = { brgt : function ($slider, value) { + // TODO: replace with call to setIndicatorValues() var brgt = parseFloat(value); var cls = $slider.data('cls'); var $ind = $slider.data('indicator'); @@ -115,9 +116,10 @@ $(this).css('background-color', 'rgb('+grey+','+grey+','+grey+')'); }; $td.each(setBgColor); - }, + }, cont : function ($slider, value) { + // TODO: replace with call to setIndicatorValues() var cont = parseFloat(value); var cls = $slider.data('cls'); var $ind = $slider.data('indicator'); @@ -128,8 +130,48 @@ $(this).css('background-color', 'rgb('+grey+','+grey+','+grey+')'); }; $td.each(setBgColor); - } + }, + + rgb : function ($slider, value) { + // TODO: replace with call to setIndicatorValues() + var val = parseFloat(value); + var cls = $slider.data('cls'); + var $ind = $slider.data('indicator'); + var $td = $ind.find('table.'+cls+'indicator td'); + var setRGBValue = function (index) { + var val = index * 32; + var r = Math.min(Math.max(Math.round(Math.pow(2, rm) * val + ra), 0), 255); + var g = Math.min(Math.max(Math.round(Math.pow(2, gm) * val + ga), 0), 255); + var b = Math.min(Math.max(Math.round(Math.pow(2, bm) * val + ba), 0), 255); + $(this).css('background-color', 'rgb('+r+','+g+','+b+')'); + }; + $td.each(setRGBValue); + } }; + + // set indicator values + var setIndicatorValues = function ($slider) { + var cls = $slider.data('cls'); + var $ind = $slider.data('indicator'); + var $td1 = $div.find('table.'+cls+'grey td'); + var $td2 = $ind.find('table.'+cls+'indicator td'); + var setGreyScale = function (index) { + // sets a series of grey values + var val = index * 32; + $(this).css('background-color', 'rgb('+val+','+val+','+val+')'); + }; + // TODO: account for current brgt/cont/rgbm/rgba values + var setRGBValue = function (index) { + var val = index * 32; + var r = Math.min(Math.max(Math.round(Math.pow(2, rm) * val + ra), 0), 255); + var g = Math.min(Math.max(Math.round(Math.pow(2, gm) * val + ga), 0), 255); + var b = Math.min(Math.max(Math.round(Math.pow(2, bm) * val + ba), 0), 255); + $(this).css('background-color', 'rgb('+r+','+g+','+b+')'); + }; + $td1.each(setGreyScale); + $td2.each(setRGBValue); + }; + // assign button actions to sliders (rotate, brightness, contrast) var setButtonActions = function () { if (fn.setButtonAction == null) { @@ -394,6 +436,7 @@ </table>\ </div>'; var $div = $(html); + // TODO: replace with setRGBValue var setGreyScale = function (index) { // sets a series of grey values var val = index * 32;