[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Alternative to pygame.Surface.subsurface
Ronald Lew wrote:
Is there another way to get a portion of an image without having a
reference to the parent? I have a 100x100 surface and would like to
have 4 surfaces that takes 1/4 of the surface so the end result would
have 4 boxes of 50x50. Here's an example
---------
| 1 | 2 |
---------
| 3 | 4 |
---------
There are a couple of ways to do something like that. You do need a
"reference to the parent" to get at the original image at _some_ point,
though.
One method is to make some new surfaces like so:
chunk_two = pygame.surface.Surface((25,25))
Then blit part of the original image onto it:
chunk_two.blit(parent_image,(0,0),(25,0))
Or you could make a Rect object (or just a tuple) to record what part of
the parent image you want to save:
chunk_two = (25,0,25,25)