我有一些用于旋转图像的代码。但是,旋转中心不等于要旋转的图像的中心。
我已经设置了图像的中心,但我不知道如何设置旋转的中心。
以下是代码:
// image code
var image = Titanium.UI.createImageView({
backgroundImage:'test.png',
width: 650,
height: 650,
center:{x:CenterX, y:CenterY},
align:'center'
});
//rotation code
image.addEventListener('touchstart', function(e){
var conv = e.source.convertPointToView({x: e.x, y:e.y}, win);
var newAngle = Math.atan2(conv.y - 500, 380 - conv.x)* -(180 / Math.PI);
diff = (newAngle - old);
});
image.addEventListener('touchmove', function(e){
var conv = e.source.convertPointToView({x: e.x, y:e.y}, win);
var newAngle = Math.atan2(conv.y - 500, 380 - conv.x)* -(180 / Math.PI);
current = (newAngle-diff);
var t = Ti.UI.create2DMatrix().rotate(current);
wheel.transform = t;
});