[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] need help with chop function
On Mon, 2006-01-09 at 22:54 -0800, Ryan Charpentier wrote:
> I'm trying to crop a surface so that it fits into a smaller area, so i
> figured that the pygame.transform.chop function is what I need.
There are two good ways to do this. One is just to blit an area from one
image to another. The other is to use a pygame Subsurface. Subsurfaces
can be kind of cool since they share the pixel data of the larger
version. Take your choice from here.
def crop1(surface, rect):
new = pygame.Surface(rect.size, surface)
new.blit(surface, (0, 0), rect)
return new
def crop2(surface, rect):
return pygame.Subsurface(surface, rect)
> Would someone mind giving me an example of how to use
> pygame.transform.chop?
The chop transform was submitted by a user that has unusual usage. It is
almost the exact opposite of a crop. The rectangle you pass to chop
defines a horizontal and vertical area that cover the dimensions of the
surface. These areas are then removed and the four corners are brought
together.