@@ -11,6 +11,7 @@ const ctx = canvas.getContext('2d');
1111const strip = document . querySelector ( '.strip' ) ;
1212const snapSound = document . querySelector ( '.sound-snap' ) ;
1313const snapLimit = document . querySelector ( '#limit' ) ;
14+ const mirror = document . querySelector ( '#mirror' ) ;
1415const alertAllMsg = document . querySelectorAll ( '.alert' ) ;
1516const alertMsgCam = document . querySelector ( '#msg_cam' ) ;
1617const alertMsgFx = document . querySelector ( '#msg_fx' ) ;
@@ -46,6 +47,10 @@ const rgbMax = document.querySelector('.max .rgb');
4647const ctrlSaturate = document . querySelector ( '#ctrl_fx_saturate' ) ;
4748const inputSaturate = document . querySelector ( '#saturate' ) ;
4849
50+ /* video resolution controls */
51+ const ctrlPixelate = document . querySelector ( '#ctrl_fx_pixelate' ) ;
52+ const inputPixelate = document . querySelector ( '#pixelate' ) ;
53+
4954/* buttons */
5055const btnAllApply = document . querySelectorAll ( '.btn_apply' ) ;
5156const btnAllClear = document . querySelectorAll ( '.btn_clear' ) ;
@@ -263,14 +268,18 @@ if (navigator.mediaDevices) {
263268
264269 const vWidth = video . videoWidth ;
265270 const vHeight = video . videoHeight ;
266- // console.log('vWidth:'+vWidth,' vHeight:'+vHeight);
271+ console . log ( 'vWidth:' + vWidth + ' / vHeight:'+ vHeight ) ;
267272
268- const ratio = vWidth / vHeight ;
269- // console.log('ratio : ', ratio );
273+ const vRatio = vWidth / vHeight ;
274+ console . log ( 'vRatio : ' , vRatio ) ;
270275
271276 const wWidth = window . innerWidth ;
272- const wHeight = window . innerHeight ;
273- // console.log('wWidth:'+wWidth,'wHeight:'+wHeight);
277+ const wHeight = wWidth * vRatio ;
278+ // const wHeight = window.innerHeight;
279+ console . log ( 'wWidth:' + wWidth + ' / wHeight:' + wHeight ) ;
280+
281+ const wRatio = wWidth / wHeight ;
282+ console . log ( 'wRatio: ' , wRatio ) ;
274283
275284 /* set canvas to W&H of window */
276285 // canvas.width = wWidth;
@@ -304,8 +313,12 @@ if (navigator.mediaDevices) {
304313 for ( var i = 0 ; i < randoms . length ; i ++ ) {
305314 randoms [ i ] *= Math . floor ( Math . random ( ) * 2 ) == 1 ? 1 : - 1 ;
306315 }
316+ console . group ( 'randoms: ' , randoms ) ;
307317 // console.log('randoms: ', randoms);
318+ console . groupEnd ( ) ;
308319
320+ /* values for F/X function */
321+ console . group ( 'selectSplit.value: ' , selectSplit . value ) ;
309322 let intsSplit = [ ] ;
310323 if ( selectSplit . value === 'stereo' ) {
311324 // expression
@@ -321,6 +334,10 @@ if (navigator.mediaDevices) {
321334 intsSplit = randoms ;
322335 }
323336 // console.log('intsSplit: ', intsSplit);
337+ console . groupEnd ( ) ;
338+
339+ /* values for F/X function */
340+ console . group ( 'selectColorize.value: ' , selectColorize . value ) ;
324341 let intsColorize = [ ] ;
325342 if ( selectColorize . value === 'red' ) {
326343 intsColorize = [ 150 , - 50 , - 50 ] ;
@@ -332,15 +349,23 @@ if (navigator.mediaDevices) {
332349 intsColorize = randoms ;
333350 }
334351 // console.log('intsColorize: ', intsColorize);
352+ console . groupEnd ( ) ;
335353
354+ /* values for F/X function */
336355 const inputSaturateVal = parseInt ( inputSaturate . value ) ;
337- console . log ( 'inputSaturateVal: ' , inputSaturateVal ) ;
356+ console . group ( 'inputSaturateVal: ' , inputSaturateVal ) ;
338357 let intsSaturate = [ 0.5 , 0.5 ] ;
339- console . log ( 'intsSaturate: ' , intsSaturate ) ;
358+ // console.log('intsSaturate: ', intsSaturate);
340359 intsSaturate = [ ( 100 - inputSaturateVal ) / 100 , inputSaturateVal / 100 ] ;
341360 console . log ( 'intsSaturate: ' , intsSaturate ) ;
361+ console . groupEnd ( ) ;
342362
343- let intPixelate = 0 ;
363+ /* values for F/X function */
364+ const inputPixelateVal = parseInt ( inputPixelate . value ) ;
365+ console . group ( 'inputPixelateVal: ' , inputPixelateVal ) ;
366+ let intPixelate = 2 ;
367+ console . log ( 'intPixelate: ' , intPixelate ) ;
368+ console . groupEnd ( ) ;
344369
345370 // console.log('selectFx.value: ',selectFx.value);
346371 // const effect = selectFx.value | '';
@@ -373,13 +398,6 @@ if (navigator.mediaDevices) {
373398 ctx . drawImage ( video , positionX , positionY , vWidth , vHeight ) ;
374399 let pixels = ctx . getImageData ( positionX , positionY , vWidth , vHeight ) ;
375400 // console.log(pixels);
376- let pixNums = pixels . data ;
377- // console.log(pixNums);
378- pixNums = pixNums . reverse ( ) ;
379- // console.log(pixNums);
380- pixels . data = pixNums ;
381- // console.log(pixels);
382- // debugger;
383401
384402 /* manipulate pixels */
385403 switch ( fx ) {
@@ -552,6 +570,15 @@ if (navigator.mediaDevices) {
552570 toggleFxControls ( ) ;
553571 } ) ;
554572
573+ let flagMirror = mirror . checked ;
574+ console . log ( 'flagMirror: ' , flagMirror ) ;
575+ /* listen for change on master F/X select/option */
576+ mirror . addEventListener ( 'change' , ( e ) => {
577+ flagMirror = ! flagMirror ;
578+ console . log ( 'mirror: ' , flagMirror ) ;
579+ fMirror ( flagMirror ) ;
580+ } ) ;
581+
555582 /* listen for change on deeper F/X select/option */
556583 inputAllSelect . forEach ( btn => {
557584 btn . addEventListener ( 'change' , ( e ) => {
@@ -574,17 +601,17 @@ if (navigator.mediaDevices) {
574601
575602 let flagSaturate = false ;
576603 inputSaturate . addEventListener ( 'change' , startStream ) ;
577- inputSaturate . addEventListener ( 'mousedown' , ( e ) => {
578- flagSaturate = true ;
579- } ) ;
580- inputSaturate . addEventListener ( 'mousemove' , ( e ) => {
581- if ( flagSaturate ) {
582- startStream ( ) ;
583- }
584- } ) ;
585- inputSaturate . addEventListener ( 'mouseup' , ( e ) => {
586- flagSaturate = false ;
587- } ) ;
604+ // inputSaturate.addEventListener('mousedown',(e)=>{
605+ // flagSaturate = true;
606+ // });
607+ // inputSaturate.addEventListener('mousemove',(e)=>{
608+ // if (flagSaturate) {
609+ // startStream();
610+ // }
611+ // });
612+ // inputSaturate.addEventListener('mouseup',(e)=>{
613+ // flagSaturate = false;
614+ // });
588615
589616 /* listen for click on all "apply" buttons */
590617 btnAllApply . forEach ( btn => {
@@ -604,6 +631,6 @@ window.addEventListener('resize', fMediaQueries);
604631
605632/* fake UI clicks to open controls */
606633startStream ( ) ;
607- // selectFx.selectedIndex = 4;
608- // toggleFxControls();
634+ selectFx . selectedIndex = 4 ;
635+ toggleFxControls ( ) ;
609636
0 commit comments