Skip to content

Latest commit

 

History

History
76 lines (43 loc) · 4.74 KB

pygame_clipping.md

File metadata and controls

76 lines (43 loc) · 4.74 KB

StackOverflow            reply.it reply.it

"You keep on learning and learning, and pretty soon you learn something no one has learned before" Richard P. Feynman


Clipping

Set clipping region

Related to set_clip()

Related Stack Overflow questions:

Circular clipping region

Related Stack Overflow questions:

Polygon clipping

📁 Minimal example - Clip polygon

Clipping with masks

Related Stack Overflow questions:

Clipping with masks

📁 Minimal example - Clipping with masks

Convert a pygame.mask.Mask to a pygame.Surface with pygame.mask.Mask.to_surface. Use setsurface to specify the source image and the unsetcolor argument to specify the transparent background:

def clip_surface(surf, mask):
    return mask.to_surface(setsurface = surf.convert_alpha(), unsetcolor = (0, 0, 0, 0))