Added crop_surface() function.
This commit is contained in:
parent
eaae218243
commit
e5951abb21
1 changed files with 13 additions and 0 deletions
13
pg.py
13
pg.py
|
@ -4,6 +4,7 @@ import pygame
|
||||||
from tools import text
|
from tools import text
|
||||||
from typing import Union, Callable
|
from typing import Union, Callable
|
||||||
|
|
||||||
|
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
log = text.Log()
|
log = text.Log()
|
||||||
|
@ -225,6 +226,18 @@ def set_rot_point(img, pos):
|
||||||
return img2, (w, h)
|
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
|
def bt_from_ca(ca, function): # bt_from_ca = button from collide able
|
||||||
return Button(function, ca)
|
return Button(function, ca)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue