当前位置:网站首页>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)
边栏推荐
- What is Win10 God Mode for?How to enable God Mode in Windows 10?
- FP7126降压恒流65536级高辉无频闪调光共阳极舞台灯RGB驱动方案
- Win11电脑一段时间不操作就断网怎么解决
- Win11 keeps popping up User Account Control how to fix it
- Publish module to NPM should be how to operate?Solutions to problems and mistake
- What should I do if I install a solid-state drive in Win10 and still have obvious lags?
- 日常-笔记
- 设备驱动框架简介
- PHY6222蓝牙5.2支持MESH组网M0内核超低功耗
- Impressions of Embrace Jetpack
猜你喜欢
cmake配置libtorch报错Failed to compute shorthash for libnvrtc.so
MATLAB图形加标注的基本方法入门简介
STM32LL库使用——SPI通信
Win10 cannot directly use photo viewer to open the picture
What is Win10 God Mode for?How to enable God Mode in Windows 10?
[STM32 Learning 1] Basic knowledge and concepts are clear
FP5207电池升压 5V9V12V24V36V42V大功率方案
使用 腾讯云搭建一个个人博客
CI24R1小模块2.4G收发模块无线通信低成本兼容si24r1/XN297超低功耗
SQL的通用语法和使用说明(图文)
随机推荐
Letter combination of LeetCode2 phone number
DP1332E内置c8051的mcu内核NFC刷卡芯片国产兼容NXP
The overlapping effect of the two surfaceviews is similar to the video and handout practice in the live effect
小T成长记-网络篇-1-什么是网络?
Win11电脑一段时间不操作就断网怎么解决
镜像法求解接地导体空腔电势分布问题
为vscode配置clangd
DP1101兼容CC1101是SUB1GHz无线收发芯片应用于智能家居
蓝牙温度检测系统(基于BT08-B蓝牙模块)
Makefile容易犯错的语法
Mysql之MVCC
cmake configure libtorch error Failed to compute shorthash for libnvrtc.so
IPV4和IPV6是什么?
Fast advanced TypeScript
Binder ServiceManager解析
SQL的通用语法和使用说明(图文)
基于最小二乘法的线性回归分析方程中系数的估计
FP7195大功率零压差全程无频闪调光DC-DC恒流芯片(兼容调光器:PWM调光,无极调光,0/1-10V调光)
【我的电赛日记(一)】HMI USART串口屏
FP5207电池升压 5V9V12V24V36V42V大功率方案