Forget_淡忘
2016-04-28 18:25
<script type="text/javascript">
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
var slider = document.getElementById("scale-range");
canvas.width = 800;
canvas.height = 543;
var scale = slider.value;
var image = new Image();
image.src = "../img/121.jpg";
image.onload = function() {
drawImageByScale(scale);
}
function drawImageByScale(scale) {
var imageWidth = canvas.width * scale;
var imageHeight = canvas.height * scale;
var sx = imageWidth / 2 - canvas.width / 2;
var sy = imageHeight / 2 - canvas.height / 2;
context.drawImage( image , sx , sy , canvas.width , canvas.height , 0 , 0 , canvas.width , canvas.height );
}
</script>
context.drawImage( image , sx , sy , canvas.width , canvas.height , 0 , 0 , canvas.width , canvas.height );这句改成context.drawImage( image , sx , sy , canvas.width , canvas.height , sx , sy , canvas.width , canvas.height );
Canvas玩转图像处理
60311 学习 · 124 问题
相似问题
回答 1
回答 2
回答 1
回答 2
回答 2