the code for moving and zooming is as follows:
var ap = function (AlloyPaper,ids,url) {
var Stage = AlloyPaper.Stage, Bitmap = AlloyPaper.Bitmap,Loader=AlloyPaper.Loader;
var stage = new Stage("-sharpourCanvas");
stage.autoUpdate=false;
var ld = new Loader();
ld.loadRes([
{ id: ids, src: "img/"+ url+".png" },
]);
ld.complete(function () {
var bmp = new Bitmap(ld.get("test"));
bmp.originX = 0.5;
bmp.originY = 0.5;
bmp.x = stage.width / 2;
bmp.y = stage.height / 2;//200;
window.img_x = bmp.x;
window.img_y = bmp.y;
stage.add(bmp);
stage.update();
var initScale = 1;
new AlloyFinger(bmp, {
multipointStart: function () {
initScale = bmp.scaleX;
},
rotate: function (evt) {
bmp.rotation += evt.angle;
stage.update();
},
pinch: function (evt) {
bmp.scaleX = bmp.scaleY = initScale * evt.scale;
stage.update();
},
pressMove: function (evt) {
bmp.x += evt.deltaX;
bmp.y += evt.deltaY;
evt.preventDefault();
window.img_x = bmp.x;
window.img_y = bmp.y;
stage.update();
}
});
});
}
I need to get the location after the move, and then use ctx.drawImage (imaged, window.img_x, window.img_y, imaged.width, imaged.height);
to add to the canvas, and finally synthesize a picture.
question 0: although the position and width and height after moving can be obtained, it is very inaccurate, and the position offset is very large.
question 1: width and height can also be obtained, but it needs * 2 to feel correct.
problem 2:drawImage method does not work on iOS