-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw_info.py
45 lines (30 loc) · 1.07 KB
/
draw_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pygame
import math
pygame.init()
class DrawInfo:
RED = 255, 0, 0
GREEN = 0, 255, 0
WHITE = 255, 255, 255
BLACK = 0, 0, 0
BACKGROUND_COLOR = BLACK
SIDE_PADDING = 100
TOP_PADDING = 150
GRADIENT = [GREEN]
SMALL_FONT = pygame.font.SysFont("Aptos", 21)
LARGE_FONT = pygame.font.SysFont("Aptos", 31)
def __init__(self, width, height, list) -> None:
self.width = width
self.height = height
self.window = pygame.display.set_mode((width, height))
pygame.display.set_caption("Sorting Algorithms Visualizer")
self.set_list(list)
def set_list(self, list) -> None:
"This function would set the list to the screen"
self.list = list
self.max_value = max(list)
self.min_value = min(list)
self.block_width = (self.width - self.SIDE_PADDING) // len(list)
self.block_height = math.floor(
(self.height - self.TOP_PADDING) / (self.max_value - self.min_value)
)
self.start_x = (self.width - (self.block_width * len(list))) // 2