旋转 2 面图像
请帮助旋转双面图像(如硬币) - 交换面的动画,当第一个图像可见时,第二个图像不可见。当我旋转图像时,直到旋转角度小于 90 度,我才会显示第一张图像,否则显示第二张图像。
现在,它在 Y 轴 (A) 上旋转,但我需要在轴上旋转图像 - 旋转图像的中心 (B)。
转换:
long aniAngle = (System.currentTimeMillis() - animationStart)*180/ANIMATION_TIME;
aniCamera.save();
if(aniAngle <= 90)
{
aniCamera.rotateY(aniAngle); // angle of current rotation
aniCamera.getMatrix(aniMatrix);
aniCamera.restore();
int centerX = x + image.getWidth()/2;
int centerY = y + iamge.getHeight()/2;
aniMatrix.preTranslate(-centerX, -centerY);
aniMatrix.postTranslate(centerX, centerY);
canvas.save();
canvas.concat(aniMatrix);
Bitmap image = angle < 90 ? image1 : image2;
if(image == image2)
angle = 180 - angle; // second image goes from rotated state to normal - degrees of rotation should decrease during animation
c.translate(x + image.getWidth()/2, y + cover.getHeight()/2); // 图像左上角坐标 (x,y)
c.rotate(angle); // angle of rotation non animated image
c.drawBitmap(image, -image.getWidth()/2, -image.getHeight()/2, null);
please help to rotate 2 sided image(like coin) - animation of swap of sides, when the first image is visible, the second is not. When I rotate image, until angle of rotation is less than 90 degrees I show the first image, the second image otherwise.
Now, its rotated over Y axis (A), but I need rotate image over axis - center of rotated image (B).
Transformations:
long aniAngle = (System.currentTimeMillis() - animationStart)*180/ANIMATION_TIME;
aniCamera.save();
if(aniAngle <= 90)
{
aniCamera.rotateY(aniAngle); // angle of current rotation
aniCamera.getMatrix(aniMatrix);
aniCamera.restore();
int centerX = x + image.getWidth()/2;
int centerY = y + iamge.getHeight()/2;
aniMatrix.preTranslate(-centerX, -centerY);
aniMatrix.postTranslate(centerX, centerY);
canvas.save();
canvas.concat(aniMatrix);
Bitmap image = angle < 90 ? image1 : image2;
if(image == image2)
angle = 180 - angle; // second image goes from rotated state to normal - degrees of rotation should decrease during animation
c.translate(x + image.getWidth()/2, y + cover.getHeight()/2); // image left top corner with coords (x,y)
c.rotate(angle); // angle of rotation non animated image
c.drawBitmap(image, -image.getWidth()/2, -image.getHeight()/2, null);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论