I'm trying to take a webcam channel - (landscape format), cut out the middle bit (portrait format) and render it on the canvas so that it fills the screen portrait 1080px to 1920px (for this I scale the bit I cut to 3.8). Then I need to flip this canvas so that the image is mirrored. I managed to cut out the middle bit and do it on the canvas ... I just can't figure out how to flip it.
Edit
Thanks to all the people who pointed me to context.scale (-1, 1) - my problem is that I am already using scale ... I think my problems are related to keeping the context, but all I try is not It worked?
<script> // Put event listeners into place window.addEventListener("DOMContentLoaded", function() { // Grab elements, create settings, etc. var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"), video = document.getElementById("video"), videoObj = { video: { mandatory: { minWidth: 1280, minHeight: 720, /*Added by Chad*/ maxWidth: 1280, maxHeight: 720 } } }, errBack = function(error) { console.log("Video capture error: ", error.code); }; // Put video listeners into place if(navigator.getUserMedia) { // Standard navigator.getUserMedia(videoObj, function(stream) { video.src = stream; video.play(); }, errBack); } else if(navigator.webkitGetUserMedia) { // WebKit-prefixed navigator.webkitGetUserMedia(videoObj, function(stream){ video.src = window.URL.createObjectURL(stream); video.play(); }, errBack); } else if(navigator.mozGetUserMedia) { // WebKit-prefixed navigator.mozGetUserMedia(videoObj, function(stream){ video.src = window.URL.createObjectURL(stream); video.play(); }, errBack); } /* video : video source tag 320,0 : the shift coords 320,180 : the canvas size 0,0 : no shift in the canvas 640,360 : important ! it's the native resolution of video source */ context.scale(3.8,3.8); function loop(){ context.drawImage(video, 450, 0, 1080, 1920, 0, 0, 720, 1280); setTimeout(loop, 1000 / 30); } loop(); }, false); </script> <video id="video" height="1080" width="1920" autoplay></video> <canvas id="canvas" height="1920" width="1080"></canvas> // Put event listeners into place window.addEventListener("DOMContentLoaded", function() { // Grab elements, create settings, etc. var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"), video = document.getElementById("video"), videoObj = { video: { mandatory: { minWidth: 1280, minHeight: 720, /*Added by Chad*/ maxWidth: 1280, maxHeight: 720 } } }, errBack = function(error) { console.log("Video capture error: ", error.code); }; // Put video listeners into place if(navigator.getUserMedia) { // Standard navigator.getUserMedia(videoObj, function(stream) { video.src = stream; video.play(); }, errBack); } else if(navigator.webkitGetUserMedia) { // WebKit-prefixed navigator.webkitGetUserMedia(videoObj, function(stream){ video.src = window.URL.createObjectURL(stream); video.play(); }, errBack); } else if(navigator.mozGetUserMedia) { // WebKit-prefixed navigator.mozGetUserMedia(videoObj, function(stream){ video.src = window.URL.createObjectURL(stream); video.play(); }, errBack); } /* video : video source tag 320,0 : the shift coords 320,180 : the canvas size 0,0 : no shift in the canvas 640,360 : important ! it's the native resolution of video source */ context.scale(-3.8,3.8); context.translate(-720,0); function loop(){ context.drawImage(video, 450, 0, 1080, 1920, 0, 0, 720, 1280); setTimeout(loop, 1000 / 30); } loop(); }, false);