我想知道如何让我的画布随浏览器窗口一起调整大小?就像现在一样,使用innerWidth和innerHeight,它只会调整到初始浏览器的宽度和高度。如何使用浏览器进行扩展?
编辑:有没有办法在不清除画布的情况下执行此操作?
JS
canvas.onmousemove = draw;
var ctx = canvas.getContext('2d');
var video = document.createElement("video");
video.setAttribute("src", "some_video.mp4");
video.autoplay = true;
var img2 = new Image;
img2.src = "some_image.png";
ctx.canvas.width = window.innerWidth;
ctx.canvas.height = window.innerHeight;
function draw(e){
var rect = canvas.getBoundingClientRect();
var x = e.clientX-rect.left-img2.width/2;
var y = e.clientY-rect.top-img2.height/2;
ctx.drawImage(video, x, y, 830, 644);
ctx.drawImage(img2, x, y, img2.width, img2.height);
}
答案 0 :(得分:0)
在string
resize