50 lines
No EOL
987 B
Python
50 lines
No EOL
987 B
Python
#!/usr/bin/python3
|
|
|
|
import pygame
|
|
from wobbl_tools import text
|
|
from typing import Union, Callable
|
|
|
|
|
|
pygame.init()
|
|
|
|
log = text.Log()
|
|
|
|
buttonlist = False
|
|
buttons = []
|
|
|
|
# colors
|
|
black = (8, 8, 8)
|
|
gray = (40, 40, 40)
|
|
light_gray = (128, 128, 128)
|
|
white = (250, 250, 250)
|
|
|
|
default_font = pygame.font.Font(pygame.font.get_default_font(), 16)
|
|
|
|
|
|
def set_rot_point(img, pos):
|
|
"""
|
|
Blits the image on an empty surface to change the center of rotation.
|
|
"""
|
|
w, h = img.get_size()
|
|
w, h = w * 2, h * 2
|
|
|
|
img2 = pygame.Surface((w, h), pygame.SRCALPHA)
|
|
img2.blit(img, (w / 2 - pos[0], h / 2 - pos[1]))
|
|
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 check_buttons(mouse_pos, pressed):
|
|
for button in buttons:
|
|
button.check(mouse_pos, pressed) |