为了账号安全,请及时绑定邮箱和手机立即绑定

不知错哪了

var canvas = document.getElementById('canvas');

var context = canvas.getCotext('2d');

var slider = document.getElementById('scale-range');

var image = new Image();


window.onload = function(){

canvas.width = 1920;

canvas.height = 1080;


var scale = slider.value;

image.src = "banner.jpg";

image.onload = function(){

drawImageByScale(scale);

slider.onmousemove = function(){

scale = slider.value;

drawImageByScale(scale);

}

}

}

function drawImageByScale(scale){

var imageWidth = 1920 * scale;

var imageHeight = 1080 * scale;

var dx = canvas.width/2 - imageWidth/2;

var dy = canvas.height/2 - imageHeight/2;

context.clearRect(0,0,canvas.width,canvas.height);

context.drawImage(image,dx,dy,imageWidth,imageHeight);

}


正在回答

2 回答

所以提示的错误是什么

0 回复 有任何疑惑可以回复我~

代码没问题

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

不知错哪了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信