diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2de24a5..b03ba00 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -8,6 +8,7 @@
+
diff --git a/src/starsky_presenter/entry.py b/src/starsky_presenter/entry.py
index c0b49f2..6cf8c8f 100644
--- a/src/starsky_presenter/entry.py
+++ b/src/starsky_presenter/entry.py
@@ -6,6 +6,7 @@ from importlib.readers import FileReader
from importlib.machinery import SourcelessFileLoader
from io import BufferedReader
from pathlib import Path
+from time import time
import yaml
from random import random, seed
@@ -37,14 +38,15 @@ def cli_main():
star_references = {}
- print(json.dumps(scenes, indent=4))
- print(json.dumps(objects, indent=4))
- print(json.dumps(scene_data, indent=4))
+ #print(json.dumps(scenes, indent=4))
+ #print(json.dumps(objects, indent=4))
+ #print(json.dumps(scene_data, indent=4))
def setup_star_instance(data: dict) -> Star:
image_path = f"resources/{data['image']}"
image = pygame.image.load(reader.open_resource(image_path))
data['image'] = image
+
star = Star(**data)
star_references[data['sid']] = star
return star
@@ -58,13 +60,21 @@ def cli_main():
screen = Screen(stars, background)
control_window = ControlWindow(screen)
+ last_time = time()
+
while control_window.is_running():
control_window.process_events()
screen.update(scene_data)
+ now = time()
+ print(f"{1/(now - last_time):.02f} fps")
+ last_time = now
screen.close()
control_window.close()
+ pygame.quit()
+
+ exit(0)
diff --git a/src/starsky_presenter/projection/screen.py b/src/starsky_presenter/projection/screen.py
index 4a541e3..5071680 100644
--- a/src/starsky_presenter/projection/screen.py
+++ b/src/starsky_presenter/projection/screen.py
@@ -18,11 +18,12 @@ class Star:
self.offset = offset
self.image = image
+
class Screen:
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))
+ self.screen = pygame.display.set_mode((1920, 1080), display=1, flags=pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.WINDOWTAKEFOCUS)
self.clock = pygame.time.Clock()
self.stars = stars
self.last = time()
@@ -30,7 +31,19 @@ class Screen:
self.active_scene = 0
self.last_scene = 0
self.scene_time: float = 0
- self.background = background
+ if background:
+ ratio_x = self.screen.get_width() / background.get_width()
+ ratio_y = self.screen.get_height() / background.get_height()
+ scaled_background = transform.rotozoom(background, 0, max(ratio_x, ratio_y))
+
+ self.bg_pos = (
+ (self.screen.get_width() - scaled_background.get_width()) / 2,
+ (self.screen.get_height() - scaled_background.get_height()) / 2
+ )
+ self.background = scaled_background
+ else:
+ self.background = None
+ self.bg_pos = None
@@ -49,27 +62,22 @@ 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)
+ self.screen.blit(self.background, self.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
- scaled = transform.rotozoom(star.image, star.alpha, star.scale)
+ computed_scale = star.scale * (self.screen.get_width() / star.image.get_width() / 100)
+ scaled = transform.rotozoom(star.image, star.alpha, computed_scale)
(w, h) = scaled.get_size()
pos = (star.x*self.screen.get_width() - w/2, star.y*self.screen.get_height() - h/2)
self.screen.blit(scaled, pos)
+
overlay = pygame.surface.Surface((1920, 1080), depth=32)
overlay.set_alpha(int(255 * (1 - self.brightness)))
self.screen.blit(overlay, (0, 0))
diff --git a/src/starsky_presenter/resources/main_window.qml b/src/starsky_presenter/resources/main_window.qml
index 07efffc..6715bfd 100644
--- a/src/starsky_presenter/resources/main_window.qml
+++ b/src/starsky_presenter/resources/main_window.qml
@@ -8,7 +8,8 @@ ApplicationWindow {
width: 800
height: 600
title: "StarSky Presenter"
- flags: Qt.FramelessWindowHint
+ flags: Qt.WindowCloseButtonHint | Qt.WindowStaysOnBottomHint
+ modality: Qt.ApplicationModal
Button {
anchors.horizontalCenter: parent.horizontalCenter
diff --git a/src/starsky_presenter/resources/objects.yml b/src/starsky_presenter/resources/objects.yml
index bb48cb4..ca79e84 100644
--- a/src/starsky_presenter/resources/objects.yml
+++ b/src/starsky_presenter/resources/objects.yml
@@ -1,18 +1,18 @@
stars:
- - sid: star-bg-01
+ - sid: star-1
x: 0.1
y: 0.1
- scale: 0.6
+ scale: 2
alpha: 0
rot: 30
offset: 0
- image: BasicStar1.png
- - sid: star-bg-02
- x: 0.3
+ image: nice-star-1.png
+ - sid: star-2
+ x: 0.25
y: 0.4
- scale: 0.8
+ scale: 2
alpha: 25
rot: 29
offset: 0
- image: BasicStar1.png
+ image: nice-star-2.png
background: background-01.jpg
\ No newline at end of file