diff options
| author | Leander <80996591+m0ntagur@users.noreply.github.com> | 2023-01-23 15:31:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-23 15:31:30 +0100 |
| commit | 7ea8f8fd31c8a39876cf115cd168ba6654ec98c6 (patch) | |
| tree | 2293019a8e63b36ddb9a6b2b5b69ee50850f973f /GUI.py | |
Add files via upload
Diffstat (limited to 'GUI.py')
| -rw-r--r-- | GUI.py | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -0,0 +1,32 @@ +import pygame
+import os
+
+class GUI():
+ def __init__(self, screen):
+ self.__screen = screen
+
+ def zeichneText(self, text: str, groeße: int, x: int, y: int, farbe: tuple):
+ font = pygame.font.Font(os.path.abspath('assets/8bit.ttf'), groeße)
+ text = font.render(text, True, farbe)
+ self.__screen.blit(text, (x-text.get_width()/2, y-text.get_height()/2))
+
+ def zeichneRoundedButton(self, text: str, groeße: int, x: int, y: int, weite: int, hoehe: int, radius: int, farbeButton: tuple, farbeText: tuple):
+
+ pygame.draw.aaline(self.__screen,farbeButton,(x-weite/2,y-hoehe/2+radius),(x-weite/2,y+hoehe/2-radius)) #left line
+ pygame.draw.aaline(self.__screen,farbeButton,(x+weite/2,y-hoehe/2+radius),(x+weite/2,y+hoehe/2-radius)) #right line
+ pygame.draw.aaline(self.__screen,farbeButton,(x-weite/2+radius,y-hoehe/2),(x+weite/2-radius,y-hoehe/2)) #top line
+ pygame.draw.aaline(self.__screen,farbeButton,(x-weite/2+radius,y+hoehe/2),(x+weite/2-radius,y+hoehe/2)) #bottom line
+
+ pygame.draw.circle(self.__screen,farbeButton,(x-weite/2+radius,y-hoehe/2+radius),radius, 0) #topleft circle
+ pygame.draw.circle(self.__screen,farbeButton,(x+weite/2-radius,y-hoehe/2+radius),radius, 0) #topright circle
+ pygame.draw.circle(self.__screen,farbeButton,(x-weite/2+radius,y+hoehe/2-radius),radius, 0) #bottomleft circle
+ pygame.draw.circle(self.__screen,farbeButton,(x+weite/2-radius,y+hoehe/2-radius),radius, 0) #bottomright circle
+
+ pygame.draw.rect(self.__screen, farbeButton, pygame.Rect(x-weite/2+radius,y-hoehe/2,weite-radius*2,hoehe)) #middle rect
+ pygame.draw.rect(self.__screen, farbeButton, pygame.Rect(x-weite/2,y-hoehe/2+radius,radius,hoehe-radius*2)) #left rect
+ pygame.draw.rect(self.__screen, farbeButton, pygame.Rect(x+weite/2-radius,y-hoehe/2+radius,radius,hoehe-radius*2)) #right rect
+
+ font = pygame.font.Font(os.path.abspath('assets/8bit.ttf'), groeße)
+ text = font.render(text, True, farbeText)
+ self.__screen.blit(text, (x-text.get_width()/2, y-text.get_height()/2))
+
|
