不知错哪了

来源:2-4 Canvas基础 使用滑杆交互

宝慕林2917688

2016-12-30 16:09

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回答

  • YnezWood
    2017-05-19 10:54:54

    所以提示的错误是什么

  • LXJ24
    2016-12-30 17:39:22

    代码没问题

Canvas玩转图像处理

canvas系列第三课,学会编写图像算法,一起玩转图像处理吧

60311 学习 · 124 问题

查看课程

相似问题