Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 获取不旋转图像的_变换_Python 3.x_Pyglet - Fatal编程技术网

Python 3.x 获取不旋转图像的_变换

Python 3.x 获取不旋转图像的_变换,python-3.x,pyglet,Python 3.x,Pyglet,我已经在pyglet中制作了一个游戏很长一段时间了,我遇到了一个无法修复的错误。我正在尝试使用image.get_transform(rotate=deg)旋转图像,但是得到了错误 AssertionError: Only 90 degree rotations are supported. 我不知道如何解决这个问题,而且度数总是在-90和90之间,所以我不明白为什么这不起作用。代码中不起作用的部分如下所示: deg=round(game.getAngle(x,y)) print(deg) s

我已经在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))

欢迎提供任何帮助

我不确定您使用的是哪个软件包,但另一种方法可能是使用rotate from scipy.image

看一下这些文件

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

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

谢谢你的回答,我明天再试试。至于软件包,我使用的是原生pyglet get_trasform(我在网上找到了一个文档),它似乎不适合我。。。运行时错误:指定的旋转平面无效。顺便说一句,旧图像就是这个东西的pyglet.resource.image