0
我有一個圖像可以在畫布上繪製其座標。例如;在畫布上調整大小和重新定位圖像調整大小
var data = {
x: 100, y: 100, // the coord when the image drawn
src: imguri,
scale: 1.6 // the scale when the image drawn
}
和縮放功能如下;
var scale = 1.6, width = canvas.width, height = canvas.height
function zoom(positiveOrNegative) {
scale += positiveOrNegative * .2
canvas.width = width * scale
canvas.height = height * scale
loadImage()
}
function loadImage() {
var img = new Image()
img.src = data.src;
img.onload = function() { context.drawImage(img, data.x, data.y) }
}
https://jsfiddle.net/bbuv53u6/
如何調整和重新定位的圖像看起來像它的輸入/輸出時,畫布大小被放大?