Add UiBar class
This commit is contained in:
parent
ed1d057be2
commit
5e76932a55
@ -1,5 +1,22 @@
|
||||
import src.ui.UiElement as UiElement
|
||||
import pygame
|
||||
|
||||
from src.ui.UiElement import UiElement
|
||||
|
||||
|
||||
class UiBar(UiElement):
|
||||
pass
|
||||
def __init__(self, rect: pygame.Rect, initialFilledPercent=100, filledBarColor=(255, 0, 0), emptyBarColor=(0, 0, 0),
|
||||
outlineColor=(75, 75, 75), outlineThickness=10):
|
||||
super().__init__(rect)
|
||||
self.filledPercent = initialFilledPercent / 100
|
||||
self.emptyBarColor = emptyBarColor
|
||||
self.barColor = filledBarColor
|
||||
|
||||
self.image = pygame.Surface((rect.width, rect.height))
|
||||
|
||||
filledPartRect = pygame.rect.Rect(outlineThickness / 2, outlineThickness / 2,
|
||||
(rect.width - outlineThickness) * self.filledPercent,
|
||||
rect.height - outlineThickness)
|
||||
self.image.fill(filledBarColor, filledPartRect)
|
||||
|
||||
pygame.draw.rect(self.image, outlineColor, pygame.rect.Rect(0, 0, rect.width, rect.height),
|
||||
outlineThickness)
|
||||
|
Loading…
Reference in New Issue
Block a user