"""pygame.transform: scale, smoothscale, rotate, rotozoom, flip, and rotating around a centre.""" import pygame pygame.init() screen = pygame.display.set_mode((640, 360)) clock = pygame.time.Clock() original = pygame.Surface((32, 20), pygame.SRCALPHA) pygame.draw.polygon(original, (244, 197, 49), [(0, 0), (32, 10), (0, 20)]) pygame.draw.rect(original, (91, 147, 230), (0, 6, 10, 8)) big_pixel = pygame.transform.scale(original, (128, 80)) # nearest neighbour: crisp pixels big_smooth = pygame.transform.smoothscale(original, (128, 80)) # filtered: smooth edges (24/32-bit only) mirrored = pygame.transform.flip(big_pixel, True, False) # flip_x, flip_y angle = 0 running = True while running: dt = clock.tick(60) / 1000 for event in pygame.event.get(): if event.type == pygame.QUIT: running = False angle = (angle + 90 * dt) % 360 screen.fill((20, 26, 46)) screen.blit(big_pixel, (20, 20)) screen.blit(big_smooth, (170, 20)) screen.blit(mirrored, (320, 20)) # Always rotate the ORIGINAL image, then re-centre the new, larger rect. rotated = pygame.transform.rotate(big_pixel, angle) rect = rotated.get_rect(center=(160, 240)) screen.blit(rotated, rect) pygame.draw.rect(screen, (90, 110, 150), rect, 1) # the rect grows as it rotates zoomed = pygame.transform.rotozoom(original, -angle, 2.5) # rotate + scale with filtering screen.blit(zoomed, zoomed.get_rect(center=(460, 240))) pygame.display.flip() pygame.quit()