I have an image to be drawn on a canvas with its coordinate. e.g;
var data = {
x: 100, y: 100, // the coord when the image drawn
src: imguri,
scale: 1.6 // the scale when the image drawn
}
and zoom function like below;
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/
how do I resize and re-position the image to look like it's been zoomed in/out when the canvas is resized?