'Scale & translate canvas
I am scaling a canvas on a point pt
context.translate(pt.x, pt.y);
var factor = Math.pow(scaleFactor, clicks);
//scaleFactor and clicks are the amount of zoom each scroll and the scroll value itself
context.scale(factor, factor);
context.translate(-pt.x, -pt.y);
current_scale *= factor;
It works well, but I have another canvas layer using css to scale, and I have to find the correct parameters to translate it at the same origin of the first canvas so that it's correctly on top of each other (originX and originY are the coordinates of this canvas layer).
originX += ?;
originY += ?;
context_display.putImageData(imageData, originX, originY);
$("#display").css("transform", "scale(" + current_scale + ")");
What calculation should I do to get originX and originY?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
