当前位置:网站首页>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)
边栏推荐
- Letter combination of LeetCode2 phone number
- FP6195耐压60V电流降压3.3V5V模块供电方案
- DP4056电源保护芯片锂电池pin对pinTP4056
- cmake配置libtorch报错Failed to compute shorthash for libnvrtc.so
- Summarize computer network super comprehensive test questions
- The SSE instructions into ARM NEON
- 推开机电的大门《电路》(二):功率计算与判断
- 【系统设计与实现】基于flink的分心驾驶预测与数据分析系统
- 使用npx -p @storybook/cli sb init安装失败,手把手搭建专属的storybook
- Binder机制(中篇)
猜你喜欢
随机推荐
C语言函数参数传递模式入门详解
MATLAB绘图命令fimplicit绘制隐函数图形入门详解
What should I do if I install a solid-state drive in Win10 and still have obvious lags?
In-depth understanding of Golang's Map
Lightweight AlphaPose
pygame绘制弧线
Publish module to NPM should be how to operate?Solutions to problems and mistake
DP4344兼容CS4344-DA转换器
镜像法求解接地导体空腔电势分布问题
FP5207电池升压 5V9V12V24V36V42V大功率方案
Win7 encounters an error and cannot boot into the desktop normally, how to solve it?
Mysql的锁
单端K总线收发器DP9637兼容L9637
FP7195大功率零压差全程无频闪调光DC-DC恒流芯片(兼容调光器:PWM调光,无极调光,0/1-10V调光)
CI24R1小模块2.4G收发模块无线通信低成本兼容si24r1/XN297超低功耗
General syntax and usage instructions of SQL (picture and text)
【我的电赛日记(一)】HMI USART串口屏
win10怎么设置不睡眠熄屏?win10设置永不睡眠的方法
jest测试,组件测试
Configure clangd for vscode