diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b6e070c..2de24a5 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -8,7 +8,7 @@
-
+
@@ -33,18 +33,18 @@
- {
+ "keyToString": {
+ "ModuleVcsDetector.initialDetectionPerformed": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
+ "RunOnceActivity.git.unshallow": "true",
+ "git-widget-placeholder": "main",
+ "last_opened_file_path": "/home/linus/Desktop/HomeLabProjects/StarSkyPresenter/src/starsky_presenter/main.py",
+ "settings.editor.selected.configurable": "preferences.pluginManager",
+ "uv run.StarSky Presenter.executor": "Run"
}
-}]]>
+}
diff --git a/src/starsky_presenter/entry.py b/src/starsky_presenter/entry.py
index 7bd23ca..c0b49f2 100644
--- a/src/starsky_presenter/entry.py
+++ b/src/starsky_presenter/entry.py
@@ -52,7 +52,10 @@ def cli_main():
stars = [ setup_star_instance(star) for star in objects["stars"] ]
- screen = Screen(stars)
+ # load the background image
+ background = pygame.image.load(reader.open_resource(f"resources/{objects['background']}"))
+
+ screen = Screen(stars, background)
control_window = ControlWindow(screen)
while control_window.is_running():
diff --git a/src/starsky_presenter/projection/screen.py b/src/starsky_presenter/projection/screen.py
index 4d5b7ea..4a541e3 100644
--- a/src/starsky_presenter/projection/screen.py
+++ b/src/starsky_presenter/projection/screen.py
@@ -1,7 +1,7 @@
import json
import pygame
-from pygame import transform, gfxdraw, Vector2
+from pygame import transform, gfxdraw, Vector2, Surface
from math import sin, cos, pi
from time import time, sleep
@@ -19,7 +19,7 @@ class Star:
self.image = image
class Screen:
- def __init__(self, stars: list[Star]) -> None:
+ def __init__(self, stars: list[Star], background: Surface | None) -> None:
if not pygame.get_init():
pygame.init()
self.screen = pygame.display.set_mode((1920, 1080))
@@ -30,6 +30,8 @@ class Screen:
self.active_scene = 0
self.last_scene = 0
self.scene_time: float = 0
+ self.background = background
+
def update(self, scene_data):
@@ -47,7 +49,19 @@ class Screen:
star.rot = weight*new[star.sid]['rot'] + (1-weight)*old[star.sid]['rot']
star.scale = weight*new[star.sid]['scale'] + (1-weight)*old[star.sid]['scale']
+ # first draw the background, if any
+ if self.background:
+ ratio_x = self.screen.get_width() / self.background.get_width()
+ ratio_y = self.screen.get_height() / self.background.get_height()
+ scaled_background = transform.rotozoom(self.background, 0, max(ratio_x, ratio_y))
+ bg_pos = (
+ (self.screen.get_width() - scaled_background.get_width()) / 2,
+ (self.screen.get_height() - scaled_background.get_height()) / 2
+ )
+ self.screen.blit(scaled_background, bg_pos)
+
+ # draw all the star objects
for star in self.stars:
update_star_scene(star, scene_data[self.last_scene], scene_data[self.active_scene], weight)
star.alpha += star.rot * delta
diff --git a/src/starsky_presenter/resources/BasicStar1.png b/src/starsky_presenter/resources/BasicStar1.png
new file mode 100644
index 0000000..6d66c87
Binary files /dev/null and b/src/starsky_presenter/resources/BasicStar1.png differ
diff --git a/src/starsky_presenter/resources/background-01.jpg b/src/starsky_presenter/resources/background-01.jpg
new file mode 100644
index 0000000..a67b9d3
Binary files /dev/null and b/src/starsky_presenter/resources/background-01.jpg differ
diff --git a/src/starsky_presenter/resources/objects.yml b/src/starsky_presenter/resources/objects.yml
index eedc835..bb48cb4 100644
--- a/src/starsky_presenter/resources/objects.yml
+++ b/src/starsky_presenter/resources/objects.yml
@@ -6,7 +6,7 @@ stars:
alpha: 0
rot: 30
offset: 0
- image: star.png
+ image: BasicStar1.png
- sid: star-bg-02
x: 0.3
y: 0.4
@@ -14,4 +14,5 @@ stars:
alpha: 25
rot: 29
offset: 0
- image: star.png
+ image: BasicStar1.png
+background: background-01.jpg
\ No newline at end of file