将一张图像旋转到另一张图像下方
我目前正在尝试旋转图像,然后在不旋转的顶部绘制图像。但每当我使用: g2d.rotate(Math.toRadians(rot), (x+15), (y+15));
之后我绘制的每张图像也会旋转。有什么方法可以旋转一张图像而不旋转其余图像(天哪,这真的很难解释)。 这是我的绘画方法:
public void draw(Graphics2D g2d)
{
move();
if(bo.px==+1)rot--;
if(bo.px==-1)rot++;
g2d.rotate(Math.toRadians(rot), (x+15), (y+15));
g2d.drawImage(img, x, y, null);//this should rotate
g2d.drawImage(shine, x, y, null);//this shouldn't
}
提前致谢。
I am currently trying to rotate an image and then drawing an image on top which isn't rotating. But whenever I use:g2d.rotate(Math.toRadians(rot), (x+15), (y+15));
every image I draw afterwards rotates as well. Is there any way I can rotate one image and not rotate the rest (gosh its really hard to explain).
Here's my paint method:
public void draw(Graphics2D g2d)
{
move();
if(bo.px==+1)rot--;
if(bo.px==-1)rot++;
g2d.rotate(Math.toRadians(rot), (x+15), (y+15));
g2d.drawImage(img, x, y, null);//this should rotate
g2d.drawImage(shine, x, y, null);//this shouldn't
}
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以保存原始变换,旋转并绘制第一个图像,然后在绘制第二个图像之前应用回原始变换。
尝试
You can save the original transform, rotate and draw the first image and then apply back the original transform before drawing the second image.
Try
绘制旋转图像后,您需要执行反向旋转以使事物恢复到原始的非旋转状态。
After you draw the rotated image you need to perform the inverse rotation to bring things back to the original non-rotated state.