Get_transform 不旋转图像

Get_transform not rotating image

我用pyglet做游戏已经有一段时间了,遇到了一个无法修复的错误。我正在尝试使用 image.get_transform(rotate=deg) 旋转图像,但出现错误

AssertionError: Only 90 degree rotations are supported.

我不知道如何解决这个问题,度数总是在 -90 到 90 之间,所以我不明白为什么这不起作用。不起作用的代码部分在这里:

deg=round(game.getAngle(x,y))
print(deg)
self.sprite=self.sprite.get_transform(rotate=deg)

getAngle 函数是这样的:

def getAngle(self,x,y):
    return math.degrees(math.atan(y/x))

如有任何帮助,我们将不胜感激

我不确定您使用的是哪个包,但替代方法可能是使用 scipy.image

的 rotate

查看文档 here

代码基本上可以归结为使用:

from scipy import ndimage
rotated_image = scipy.ndimage.rotate(old_image, angle)