当前位置:网站首页>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)
边栏推荐
- Summarize computer network super comprehensive test questions
- DP1332E内置c8051的mcu内核NFC刷卡芯片国产兼容NXP
- Yolov5 official code reading - prior to transmission
- Redis的线程模型
- Please make sure you have the correct access rights and the repository exists.问题解决
- 二叉树遍历之后序遍历(非递归、递归)入门详解
- 基于最小二乘法的线性回归分析方程中系数的估计
- KiCad常用快捷键
- ASR6601牛羊定位器芯片GPS国内首颗支持LoRa的LPWAN SoC
- DP4056电源保护芯片锂电池pin对pinTP4056
猜你喜欢

FP5139电池与适配器供电DC-DC隔离升降压电路反激电路电荷泵电路原理图

cmake配置libtorch报错Failed to compute shorthash for libnvrtc.so

CS4398音频解码替代芯片DP4398完全兼容DAC解码

FP7126降压恒流65536级高辉无频闪调光共阳极舞台灯RGB驱动方案

二叉树创建之层次法入门详解

FP7195转模拟恒流调光芯片在机器视觉光源的应用优势

win10怎么设置不睡眠熄屏?win10设置永不睡眠的方法

mysql的索引结构为什么选用B+树?

pygame绘制弧线

What should I do if Windows 10 cannot connect to the printer?Solutions for not using the printer
随机推荐
Mysql之MVCC
Mysql connection error solution
【系统设计与实现】基于flink的分心驾驶预测与数据分析系统
Binder机制(下篇)
系统线性、时不变、因果判断
BLE蓝牙5.2-PHY6222系统级芯片(SoC)智能手表/手环
Configure clangd for vscode
ASR6601牛羊定位器芯片GPS国内首颗支持LoRa的LPWAN SoC
Mapreduce环境详细搭建和案例实现
FP7122降压恒流内置MOS耐压100V共正极阳极PWM调光方案原理图
MATLAB绘图函数plot详解
pygame拖动条的实现方法
Daily - Notes
Failed to install using npx -p @storybook/cli sb init, build a dedicated storybook by hand
FP7126降压恒流65536级高辉无频闪调光共阳极舞台灯RGB驱动方案
DP4301无线收发SUB-1G芯片兼容CC1101智能家居
13.56MHZ刷卡芯片CI521兼容cv520/ci520支持A卡B卡MIFARE协议
FP7195转模拟恒流调光芯片在机器视觉光源的应用优势
Win10电脑不能读取U盘怎么办?不识别U盘怎么解决?
Open the door of power and electricity "Circuit" (2): Power Calculation and Judgment