[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Storing Rect Pixels



On Mon, 2006-06-12 at 15:16 -0700, Geekius Maximus wrote:
> Does anyone know of a way to take a rect, and store the pixel
> arrangement inside of it? To put it another way, can I "copy" a part
> of the screen into a variable, and then "paste" it back on later at
> the same spot?

You can blit from the screen to store part of it. Use the optional last
argument to blit to only use a subsection of the source.


# save an area from the screen
saveArea = pygame.Rect(100, 100, 50, 40)
temporary = pygame.Surface(saveArea.size)
temporary.blit(screen, (0, 0), saveArea)

# ... later on, blit that back to the screen
screen.blit(temporary, saveArea)