Update
The reason why this won't work is as follows: when applying CSS transform on an element it will only be rendered by browser that way. If you try to use for example the video element and draw its content to canvas the original content will be drawn excluding the CSS transformation.
So in order for this to work you will have to transform the canvas' context before drawing the video to it.
For example - for this to be convenient you can use this function will set all the transforms before the video is drawn:
function updateCanvas() {
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.translate(canvas.width * 0.5, canvas.height * 0.5);
ctx.rotate(rotate * Math.PI / 180);
ctx.scale(zoom, zoom);
ctx.translate(-canvas.width * 0.5, -canvas.height * 0.5);
}
When you alter a transform, for example rotate, you simply do this:
document.getElementById("rotateright").addEventListener("click", function () {
rotate = rotate - 5;
updateCanvas();
}, false);
Now you can run the loop (here using requestAnimationFrame
) and the video will be drawn as you intent:
function loop() {
ctx.drawImage(video, 14, 110, 300, 550);
requestAnimationFrame(loop);
}