旋转 2 面图像

发布于 2024-11-19 23:11:29 字数 1464 浏览 2 评论 0原文

请帮助旋转双面图像(如硬币) - 交换面的动画,当第一个图像可见时,第二个图像不可见。当我旋转图像时,直到旋转角度小于 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);

https://i.sstatic.net/TCRde. .png

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);

https://i.sstatic.net/TCRde.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文