--- /dev/null
+import pygame
+from color import Color
+
+
+class Image:
+
+ def __init__(self, x, y, image_path, border_color=Color.BLACK, border_width=0):
+ self.x = x
+ self.y = y
+ self.image_path = image_path
+ self.image = pygame.image.load(self.image_path)
+ self.width = self.image.get_width()
+ self.height = self.image.get_height()
+
+ self.border_color = border_color
+ self.border_width = border_width
+
+ def get_width(self):
+ return self.width
+
+ def get_height(self):
+ return self.height
+
+ def set_position(self, x, y):
+ self.x = x
+ self.y = y
+
+ def move(self, dx, dy):
+ self.x += dx
+ self.y += dy
+
+ def set_image(self, image_path):
+ self.image_path = image_path
+ self.image = pygame.image.load(self.image_path)
+ self.width = self.image.get_width()
+ self.height = self.image.get_height()
+
+ def set_border_color(self, border_color):
+ self.border_color = border_color
+
+ def resize(self, width, height):
+ self.image = pygame.transform.scale(self.image, (width, height))
+ self.width = width
+ self.height = height
+
+ def draw(self, screen):
+ screen.blit(self.image, (self.x, self.y))
+ pygame.draw.rect(screen, self.border_color, (self.x, self.y, self.width, self.height), self.border_width)
from text import Text, Label
from button import Button
from container import Container
+from image import Image
+
pygame.init()
lambda: print("Goodbye World"))
f = Container(400, 100, Color.WHITE, Color.BLACK, 1, 15, 20, 50, True, [d, e])
f.add_child(a)
+
+g = Image(0, -400, "image.PNG", Color.BLACK, 1)
+g.resize(600, 400)
+
is_running = True
while is_running:
for event in pygame.event.get():
f.move(delta * -10, 0)
f.draw(screen)
+ g.move(0, delta * 50)
+ g.draw(screen)
+
pygame.display.update()
delta = clock.tick(60) / 1000 # Seconds since last frame