added background functionality
This commit is contained in:
parent
eb6547eb1a
commit
7403c84df8
24
.idea/workspace.xml
generated
24
.idea/workspace.xml
generated
@ -8,7 +8,7 @@
|
|||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/entry.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/entry.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/entry.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/entry.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/projection/screen.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/projection/screen.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/projection/screen.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/projection/screen.py" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/resources/scenes.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/resources/scenes.yml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/starsky_presenter/resources/objects.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/starsky_presenter/resources/objects.yml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -33,18 +33,18 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"last_opened_file_path": "/home/linus/Desktop/HomeLabProjects/StarSkyPresenter/src/starsky_presenter/main.py",
|
"last_opened_file_path": "/home/linus/Desktop/HomeLabProjects/StarSkyPresenter/src/starsky_presenter/main.py",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"uv run.StarSky Presenter.executor": "Run"
|
"uv run.StarSky Presenter.executor": "Run"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/resources" />
|
<recent name="$PROJECT_DIR$/resources" />
|
||||||
|
|||||||
@ -52,7 +52,10 @@ def cli_main():
|
|||||||
|
|
||||||
stars = [ setup_star_instance(star) for star in objects["stars"] ]
|
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)
|
control_window = ControlWindow(screen)
|
||||||
|
|
||||||
while control_window.is_running():
|
while control_window.is_running():
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
from pygame import transform, gfxdraw, Vector2
|
from pygame import transform, gfxdraw, Vector2, Surface
|
||||||
from math import sin, cos, pi
|
from math import sin, cos, pi
|
||||||
|
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
@ -19,7 +19,7 @@ class Star:
|
|||||||
self.image = image
|
self.image = image
|
||||||
|
|
||||||
class Screen:
|
class Screen:
|
||||||
def __init__(self, stars: list[Star]) -> None:
|
def __init__(self, stars: list[Star], background: Surface | None) -> None:
|
||||||
if not pygame.get_init():
|
if not pygame.get_init():
|
||||||
pygame.init()
|
pygame.init()
|
||||||
self.screen = pygame.display.set_mode((1920, 1080))
|
self.screen = pygame.display.set_mode((1920, 1080))
|
||||||
@ -30,6 +30,8 @@ class Screen:
|
|||||||
self.active_scene = 0
|
self.active_scene = 0
|
||||||
self.last_scene = 0
|
self.last_scene = 0
|
||||||
self.scene_time: float = 0
|
self.scene_time: float = 0
|
||||||
|
self.background = background
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def update(self, scene_data):
|
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.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']
|
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:
|
for star in self.stars:
|
||||||
update_star_scene(star, scene_data[self.last_scene], scene_data[self.active_scene], weight)
|
update_star_scene(star, scene_data[self.last_scene], scene_data[self.active_scene], weight)
|
||||||
star.alpha += star.rot * delta
|
star.alpha += star.rot * delta
|
||||||
|
|||||||
BIN
src/starsky_presenter/resources/BasicStar1.png
Normal file
BIN
src/starsky_presenter/resources/BasicStar1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/starsky_presenter/resources/background-01.jpg
Normal file
BIN
src/starsky_presenter/resources/background-01.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 412 KiB |
@ -6,7 +6,7 @@ stars:
|
|||||||
alpha: 0
|
alpha: 0
|
||||||
rot: 30
|
rot: 30
|
||||||
offset: 0
|
offset: 0
|
||||||
image: star.png
|
image: BasicStar1.png
|
||||||
- sid: star-bg-02
|
- sid: star-bg-02
|
||||||
x: 0.3
|
x: 0.3
|
||||||
y: 0.4
|
y: 0.4
|
||||||
@ -14,4 +14,5 @@ stars:
|
|||||||
alpha: 25
|
alpha: 25
|
||||||
rot: 29
|
rot: 29
|
||||||
offset: 0
|
offset: 0
|
||||||
image: star.png
|
image: BasicStar1.png
|
||||||
|
background: background-01.jpg
|
||||||
Loading…
x
Reference in New Issue
Block a user