@@ -39,7 +39,7 @@ const selectSplit = document.querySelector('#split');
3939
4040/* video croma key controls */
4141// const ctrlChromaKey = document.querySelector('#ctrl_fx_chroma');
42- const inputAllChromaKey = document . querySelectorAll ( '#ctrl_fx_chroma input' ) ;
42+ const inputAllChromaKey = document . querySelectorAll ( '#ctrl_fx_chroma . input-range ' ) ;
4343const rgbMin = document . querySelector ( '.min .rgb' ) ;
4444const rgbMax = document . querySelector ( '.max .rgb' ) ;
4545
@@ -128,6 +128,39 @@ function fChromaKeyInputs (group) {
128128}
129129fChromaKeyInputs ( inputAllChromaKey ) ;
130130
131+ /**
132+ * set background color of chroma range input labels. also put value number
133+ * in the UI.
134+ * @return {[type] } [description]
135+ */
136+ function fUpdateInput ( input ) {
137+ console . group ( 'START fUpdateInput: ' , input ) ;
138+ console . log ( 'input.value: ' , input . value ) ;
139+ console . log ( 'input.min: ' , input . min ) ;
140+ console . log ( 'input.max: ' , input . max ) ;
141+ console . log ( 'input.diff: ' , Math . abs ( input . min - input . max ) ) ;
142+ const valRange = Math . abs ( input . min - input . max ) ;
143+ if ( input . type === 'range' || input . type === 'number' ) {
144+ const label = input . parentElement ;
145+ label . querySelector ( "span" ) . querySelector ( "code" ) . innerHTML = input . value ;
146+ // const cell = label.parentElement;
147+ let bg , br ;
148+ if ( input . id === 'saturate' ) {
149+ bg = `hsla(0,${ input . value / 2 } %,50%,1)` ;
150+ } else if ( input . id === 'pixelate' ) {
151+ bg = `#808080` ;
152+ br = `${ 1 / input . value } rem` ;
153+ }
154+ label . querySelector ( "code" ) . style . backgroundColor = bg ;
155+ label . querySelector ( "code" ) . style . borderRadius = br ;
156+ // label.querySelector("input").style.backgroundColor = bg;
157+ }
158+ console . groupEnd ( ) ;
159+ }
160+ inputAllRange . forEach ( ( input ) => {
161+ fUpdateInput ( input ) ;
162+ } ) ;
163+
131164/**
132165 * [toggleFxControls description]
133166 * @return {[type] } [description]
@@ -313,9 +346,7 @@ if (navigator.mediaDevices) {
313346 for ( var i = 0 ; i < randoms . length ; i ++ ) {
314347 randoms [ i ] *= Math . floor ( Math . random ( ) * 2 ) == 1 ? 1 : - 1 ;
315348 }
316- console . group ( 'randoms: ' , randoms ) ;
317- // console.log('randoms: ', randoms);
318- console . groupEnd ( ) ;
349+ console . log ( 'randoms: ' , randoms ) ;
319350
320351 /* values for F/X function */
321352 console . group ( 'selectSplit.value: ' , selectSplit . value ) ;
@@ -598,23 +629,32 @@ if (navigator.mediaDevices) {
598629 /* listen for change on deeper F/X select/option */
599630 inputAllSelect . forEach ( btn => {
600631 btn . addEventListener ( 'change' , ( e ) => {
601- console . log ( 'inputAllSelect: ' , e . target ) ;
632+ // console.log('inputAllSelect: ',e.target);
602633 startStream ( ) ;
603634 } )
604635 } ) ;
605636
606- inputAllChromaKey . forEach ( input => {
607- input . addEventListener ( 'change' , ( e ) => {
608- fChromaKeyInputs ( inputAllChromaKey ) ;
609- } )
637+ inputSaturate . addEventListener ( 'change' , ( e ) => {
638+ fUpdateInput ( inputSaturate ) ;
639+ } ) ;
640+
641+ inputPixelate . addEventListener ( 'change' , ( e ) => {
642+ fUpdateInput ( inputPixelate ) ;
610643 } ) ;
611644
612645 inputAllChromaKey . forEach ( input => {
613- input . addEventListener ( 'mousemove ' , ( e ) => {
646+ input . addEventListener ( 'change ' , ( e ) => {
614647 fChromaKeyInputs ( inputAllChromaKey ) ;
615648 } )
616649 } ) ;
617650
651+ /* update UI on mousemove */
652+ // inputAllChromaKey.forEach(input => {
653+ // input.addEventListener('mousemove',(e)=>{
654+ // fChromaKeyInputs(inputAllChromaKey);
655+ // })
656+ // });
657+
618658 let flagSaturate = false ;
619659 inputSaturate . addEventListener ( 'change' , startStream ) ;
620660 // inputSaturate.addEventListener('mousedown',(e)=>{
@@ -647,6 +687,6 @@ window.addEventListener('resize', fMediaQueries);
647687
648688/* fake UI clicks to open controls */
649689startStream ( ) ;
650- selectFx . selectedIndex = 4 ;
690+ selectFx . selectedIndex = 5 ;
651691toggleFxControls ( ) ;
652692
0 commit comments