From 7ea8f8fd31c8a39876cf115cd168ba6654ec98c6 Mon Sep 17 00:00:00 2001 From: Leander <80996591+m0ntagur@users.noreply.github.com> Date: Mon, 23 Jan 2023 15:31:30 +0100 Subject: Add files via upload --- GUI.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 GUI.py (limited to 'GUI.py') diff --git a/GUI.py b/GUI.py new file mode 100644 index 0000000..d1c6f96 --- /dev/null +++ b/GUI.py @@ -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)) + -- cgit v1.3.1