2021-09-01 17:32:53 +02:00
|
|
|
import math
|
2021-09-01 11:26:29 +02:00
|
|
|
from numpy import array as a
|
|
|
|
import pygame
|
|
|
|
|
|
|
|
|
|
|
|
class Screen:
|
|
|
|
def __init__(self, width: float, height: float, font_size: int, screen_size: a):
|
|
|
|
pygame.init()
|
|
|
|
|
|
|
|
self.width = width
|
|
|
|
self.height = height
|
|
|
|
self.size = a([float(width), float(height)])
|
|
|
|
self.screen_size = a(screen_size)
|
|
|
|
self.matrix = a([
|
|
|
|
[screen_size[0] / width, 0],
|
|
|
|
[0, screen_size[1] / height]
|
|
|
|
])
|
2021-09-01 17:32:53 +02:00
|
|
|
self.pd = abs(self.matrix[0, 0] * self.matrix[1, 1]) # positive determinant
|
|
|
|
self.pd_ = math.sqrt(self.pd)
|
2021-09-01 11:26:29 +02:00
|
|
|
|
|
|
|
self.s_ = pygame.Surface([width, height])
|
|
|
|
self.s = pygame.display.set_mode(screen_size)
|
|
|
|
|
|
|
|
self.font_size = font_size
|
|
|
|
|
|
|
|
self.center = a([width, height]) / 2
|
2021-09-01 17:32:53 +02:00
|
|
|
|
|
|
|
def save(self, path):
|
|
|
|
pygame.image.save(self.s, path)
|