@@ -80,9 +80,11 @@ const constraints = {audio: false, video: true};
8080 */
8181
8282hide ( video ) ;
83+ show ( btnOn ) ;
84+ hide ( btnOff ) ;
8385// hide(selectFx);
8486// selectFx.disabled = true;
85- document . querySelector ( '#ctrl_strip label span' ) . innerHTML = `Limit? ( ${ stripMax } ) ` ;
87+ document . querySelector ( '#ctrl_strip label span .value ' ) . innerHTML = `${ stripMax } ` ;
8688
8789/**
8890 * FUNCTIONS
@@ -100,7 +102,7 @@ function fChromaKeyInputs (group) {
100102 if ( input . type === 'range' || input . type === 'number' ) {
101103 levels [ input . name ] = input . value ;
102104 const label = input . parentElement ;
103- label . querySelector ( "span" ) . querySelector ( "code ") . innerHTML = input . value ;
105+ label . querySelector ( "span .value " ) . innerHTML = input . value ;
104106 const cell = label . parentElement ;
105107 let bg ;
106108 // console.log(cell.classList[0]+' '+cell.classList[1]+': '+input.value);
@@ -151,7 +153,7 @@ function fUpdateInput (input) {
151153 bg = `#808080` ;
152154 br = `${ 1 / input . value } rem` ;
153155 } else {
154- console . error ( ' NOT saturate OR pixelate!' ) ;
156+ console . warn ( ' NOT saturate OR pixelate!' ) ;
155157 }
156158 label . querySelector ( "code" ) . style . backgroundColor = bg ;
157159 label . querySelector ( "code" ) . style . borderRadius = br ;
@@ -163,6 +165,18 @@ inputAllRange.forEach((input)=>{
163165 fUpdateInput ( input ) ;
164166} ) ;
165167
168+
169+ function fMirror ( ) {
170+ if ( mirror . checked ) {
171+ console . log ( 'FLIP IT' ) ;
172+ canvas . style . transform = 'scale(-1,1)' ;
173+ } else {
174+ console . log ( 'DON\'T FLIP IT' ) ;
175+ canvas . style . transform = 'scale(1,1)' ;
176+ }
177+ }
178+ fMirror ( ) ;
179+
166180/**
167181 * [toggleFxControls description]
168182 * @return {[type] } [description]
@@ -201,7 +215,7 @@ function fMediaQueries () {
201215 /* switch input type between 'number'/'range' based on window size. */
202216 input . type = window . innerWidth < 800 ? 'number' : 'range' ;
203217 /* show/hide color swatch based on window size (to match input type). */
204- input . parentElement . querySelector ( "span code " ) . style . display = window . innerWidth < 800 ? 'none' : 'inline' ;
218+ input . parentElement . querySelector ( "span .value " ) . style . display = window . innerWidth < 800 ? 'none' : 'inline' ;
205219 }
206220 /* show/hide min rgb color label text based on window size. */
207221 // rgbMin.querySelector("span").style.display = window.innerWidth<800 ? 'none' : 'inline';
@@ -259,7 +273,8 @@ if (navigator.mediaDevices) {
259273 /* reset & enable the F/X select/option */
260274 // toggleButton(selectFx,'on');
261275
262- toggleButton ( btnOff , 'on' ) ;
276+ hide ( btnOn ) ;
277+ show ( btnOff ) ;
263278 toggleButton ( btnSnap , 'on' ) ;
264279
265280 } else {
@@ -275,7 +290,8 @@ if (navigator.mediaDevices) {
275290 /* reset & disable the F/X select/option */
276291 // toggleButton(selectFx,'off');
277292
278- toggleButton ( btnOff , 'off' ) ;
293+ show ( btnOn ) ;
294+ hide ( btnOff ) ;
279295 toggleButton ( btnSnap , 'off' ) ;
280296
281297 toggleFxControls ( ) ;
@@ -308,37 +324,40 @@ if (navigator.mediaDevices) {
308324 const vRatio = vWidth / vHeight ;
309325 console . log ( 'vRatio: ' , vRatio ) ;
310326
311- const wWidth = window . innerWidth ;
312- const wHeight = wWidth * vRatio ;
313- // const wHeight = window.innerHeight;
327+ let wWidth = window . innerWidth ;
328+ let wHeight = window . innerHeight ;
314329 console . log ( 'wWidth:' + wWidth + ' / wHeight:' + wHeight ) ;
315330
316- const wRatio = wWidth / wHeight ;
317- console . log ( 'wRatio: ' , wRatio ) ;
331+ // const wRatio = wWidth/wHeight;
332+ // console.log('wRatio: ', wRatio);
318333
319334 /* set canvas to W&H of window */
320- // canvas.width = wWidth;
321- // canvas.height = wHeight;
335+ if ( vWidth > wWidth ) {
336+ console . info ( 'vWidth > wWidth' ) ;
337+ if ( vHeight > wHeight ) {
338+ console . info ( 'vHeight > wHeight' ) ;
339+ // shrink horizontally...
340+ // wWidth = wHeight * vRatio;
341+ } else {
342+ console . info ( 'vHeight <= wHeight' ) ;
343+ // enlarge vertically to fill canvas with video...
344+ // wHeight = wWidth * vRatio;
345+ }
346+ } else {
347+ console . info ( 'vWidth <= wWidth' ) ;
348+ if ( vHeight > wHeight ) {
349+ console . info ( 'vHeight > wHeight' ) ;
350+ } else {
351+ console . info ( 'vHeight <= wHeight' ) ;
352+ }
353+ }
354+ console . log ( 'wWidth:' + wWidth + ' / wHeight:' + wHeight ) ;
355+ canvas . width = wWidth ;
356+ canvas . height = wHeight ;
322357
323358 /* center the canvas */
324- // positionX = (wWidth - vWidth)/2;
325- // positionY = (wHeight - vHeight)/2;
326-
327- // if (vWidth < wWidth && vHeight > wHeight) {
328- // console.log('video taller than window');
329- // // stretch video vertically...
330- // canvas.width = vWidth;
331- // canvas.height = wHeight;
332- // } else if (vWidth > wWidth && vHeight < wHeight) {
333- // console.log('video wider than window');
334- // // stretch video horizontally...
335- // canvas.width = wWidth;
336- // canvas.height = vHeight;
337- // } else {
338- // console.log('video ??? than window');
339- canvas . width = vWidth ;
340- canvas . height = vHeight ;
341- // }
359+ positionX = ( wWidth - vWidth ) / 2 ;
360+ positionY = ( wHeight - vHeight ) / 2 ;
342361
343362 let randoms = [ ] ; // random numbers
344363 randoms . push ( Math . floor ( Math . random ( ) * 25 ) + Math . floor ( Math . random ( ) * 250 ) ) ;
@@ -510,7 +529,7 @@ if (navigator.mediaDevices) {
510529
511530 if ( stripLen > 0 ) {
512531 strip . style . display = 'flex' ;
513- document . querySelector ( '#ctrl_strip legend' ) . innerHTML = `snapshots ( ${ stripLen } ) ` ;
532+ document . querySelector ( '#ctrl_strip legend .value ' ) . innerHTML = `${ stripLen } ` ;
514533 toggleButton ( btnClearStrip , 'on' ) ;
515534 // btnClearStrip.disabled = false;
516535 // btnClearStrip.classList.remove('disabled');
@@ -551,7 +570,7 @@ if (navigator.mediaDevices) {
551570 toggleButton ( btnClearStrip , 'off' ) ;
552571 // btnClearStrip.disabled = true;
553572 // btnClearStrip.classList.add('disabled');
554- document . querySelector ( '#ctrl_strip legend' ) . innerHTML = 'snapshots ' ;
573+ document . querySelector ( '#ctrl_strip legend .value ' ) . innerHTML = '0 ' ;
555574 console . groupEnd ( ) ;
556575 }
557576
@@ -617,16 +636,7 @@ if (navigator.mediaDevices) {
617636 // });
618637
619638 /* listen for change on mirror checkbox */
620- mirror . addEventListener ( 'change' , ( e ) => {
621- // console.log('mirror: ',mirror.checked);
622- if ( mirror . checked ) {
623- console . log ( 'FLIP IT' ) ;
624- canvas . style . transform = 'scale(-1,1)' ;
625- } else {
626- console . log ( 'DON\'T FLIP IT' ) ;
627- canvas . style . transform = 'scale(1,1)' ;
628- }
629- } ) ;
639+ mirror . addEventListener ( 'change' , fMirror ) ;
630640
631641 /* listen for change on deeper F/X select/option */
632642 inputAllSelect . forEach ( btn => {
@@ -689,6 +699,6 @@ window.addEventListener('resize', fMediaQueries);
689699
690700/* fake UI clicks to open controls */
691701startStream ( ) ;
692- selectFx . selectedIndex = 5 ;
702+ selectFx . selectedIndex = 3 ;
693703toggleFxControls ( ) ;
694704
0 commit comments