I want to display an image of a star that grows bigger by 1% every second.
I use the pygame.transform.rotozoom function to do so.
When using rotozoom, the star indeed grows bigger, but its drawing rectangle doesn't grow enough, making the star blitting out of its rectangle bounds.
The star then appears cut.
The original star.png
The result with the program
I tried searching for a solution to expand the rectangle but I did not succeed.
I also tried pygame.transform.scale but it didn't work at all, the star didn't grow or was distorded depending on how much its dimensions were incremented.
Does anyone has any solution for the drawing rectangle or an alternative ?
Here's my program :
import pygame
import time
pygame.init()
star = pygame.image.load('assets/star.png')
bg = pygame.image.load('assets/background.jpg')
_w = pygame.display.set_mode((480,480))
cpt = 0
Done = False
while not Done :
pygame.time.delay(1000)
pygame.display.flip()
_w.blit(bg, (0,0))
_w.blit(star, (0,0))
star = pygame.transform.rotozoom(star, 0, 1.01)
cpt += 1
if cpt == 20 :
Done = True
question from:
https://stackoverflow.com/questions/65899193/pygame-rotozoom-rescaling-the-image-out-of-bounds 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…