I have the following html template:
<div className="page"> <video id="video" autoPlay/> <canvas id="canvas"/> <div class="btn-wrapper"> <button onClick={this._takePhoto}>Snap Photo</button> </div> </div>
Here is a screenshot of my application. At the top you can see <video>
and at the bottom <canvas/>
(focus in devtools).

Problem: draw a <video/>
image on <canvas/>
I have to use these weird coefficients:
const canvas = document.getElementById('canvas'), context = canvas.getContext("2d"), video = document.getElementById('video');
Question: why should I use coefficients if <video/>
and <canvas/>
have the same width / height?
If I do the same, but without coefficients, for example
context.drawImage(video, 0, 0, video.clientWidth, video.clientHeight, 0, 0, canvas.clientWidth, canvas.clientHeight); //OR context.drawImage(video, 0, 0, video.clientWidth, video.clientHeight, 0, 0, video.clientWidth, video.clientHeight); //OR context.drawImage(video, 0, 0, canvas.clientWidth, canvas.clientHeight, 0, 0, canvas.clientWidth, canvas.clientHeight);
I get a larger image:

UPDATE
My new version for resizing:
_resizeCanvas() { const canvas = document.getElementById('canvas'), video = document.getElementById('video'); const width = +window.getComputedStyle(video, null).getPropertyValue('width').replace('px', ''), height = +window.getComputedStyle(video, null).getPropertyValue('height').replace('px', ''); video.width = width; video.height = height; canvas.width = width; canvas.height = height; },
UPDATE 2 - add a sample script
Here is my sample script