Added crop_surface() function.

This commit is contained in:
The Wobbler 2024-01-05 22:43:49 +01:00
parent eaae218243
commit e5951abb21

13
pg.py
View file

@ -4,6 +4,7 @@ import pygame
from tools import text
from typing import Union, Callable
pygame.init()
log = text.Log()
@ -225,6 +226,18 @@ def set_rot_point(img, pos):
return img2, (w, h)
def crop_surface(surface: pygame.Surface, position: tuple, size: tuple):
new_surface = pygame.Surface(size, flags=pygame.SRCALPHA)
x, y = position
x = -x
y = -y
new_surface.blit(surface, (x, y))
return new_surface
def bt_from_ca(ca, function): # bt_from_ca = button from collide able
return Button(function, ca)