当前位置:网站首页>pygame image rotate continuously
pygame image rotate continuously
2022-08-02 15:27:00 【Tianshan has no longevity tea】
We can know by searching that the method of image rotation in pygame is pygame.transform.rotate(), but in actual use, we will find that if we want to continuously rotate an object, simplyUsing this method will cause the image to be distorted and completely lose its original appearance.
After research, it is found that the reason for the image distortion is that after each rotation using the above method, the center point of the image will change, so our solution is to set the rotation center to remain unchanged every time it rotates.The code is as follows:
x = 0y = 0# import original imageimage_raw = pygame.image.load("your image").convert_alpha()# set the center of rotationcore = (x,y)# Set the angle (0~360)angle = 60# rotate the imageimage = pygame.transform.rotate(image_raw, angle)# Draw the image and set the center position, note that the center here must be a tuple tupleself.screen.blit(image, image.get_rect(center=tuple(core)))If we need to rotate continuously and change the position of the rotation center, just adjust the values of core and angle.Note that the range of angle uses the angle system (0~360)
边栏推荐
猜你喜欢
随机推荐
Win7怎么干净启动?如何只加载基本服务启动Win7系统
FP7195降压恒流PWM转模拟调光零压差大功率驱动方案原理图
flink+sklearn——使用jpmml实现flink上的机器学习模型部署
CMAKE
How to add a one-key shutdown option to the right-click menu in Windows 11
A clean start Windows 7?How to load only the basic service start Windows 7 system
In-depth understanding of Golang's Map
二叉树遍历之后序遍历(非递归、递归)入门详解
General syntax and usage instructions of SQL (picture and text)
2021-10-14
发布模块到npm应该怎么操作?及错误问题解决方案
pytorch模型转libtorch和onnx格式的通用代码
Do Windows 10 computers need antivirus software installed?
FP7195大功率零压差全程无频闪调光DC-DC恒流芯片(兼容调光器:PWM调光,无极调光,0/1-10V调光)
source /build/envsetup.sh和lunch)
CS4398音频解码替代芯片DP4398完全兼容DAC解码
二叉树创建之层次法入门详解
Win10 cannot directly use photo viewer to open the picture
Win11没有本地用户和组怎么解决
Win11 computer off for a period of time without operating network how to solve









