Skip to content

Commit

Permalink
Added StaticStars class
Browse files Browse the repository at this point in the history
  • Loading branch information
goodtimes-code committed Dec 31, 2023
1 parent d99559f commit 6cd2d68
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
32 changes: 32 additions & 0 deletions osc-receiver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,38 @@ def update(self):
self.point_list.append(laser_point)

super().update()


class StaticStars(LaserObject):
def __init__(self, group=0):
super().__init__()
self.group = group
self.star_count = global_data.parameters.get('stars_amount', 50) # Default to 50 stars if not specified
self.generate_stars()

def generate_stars(self):
self.point_list = []
for _ in range(self.star_count):
# Add the actual star point
x = random.randint(0, int(global_data.config['laser_output']['width']))
y = random.randint(0, int(global_data.config['laser_output']['height']))
star_point = LaserPoint(x, y)
star_point.set_color(255, 255, 255) # White color for stars
self.point_list.append(star_point)

# Add a blank point after each star to ensure the laser is off when moving to the next point
blank_point = LaserPoint(x, y)
blank_point.set_color(0, 0, 0)
self.point_list.append(blank_point)

def update(self):
if 'stars_amount' in global_data.parameters and self.star_count != global_data.parameters['stars_amount']:
self.star_count = global_data.parameters['stars_amount']
self.generate_stars()
super().update()






Expand Down
5 changes: 3 additions & 2 deletions osc-receiver/osc_input.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from models import LaserPoint, Blank, StaticLine, StaticWave, Effect, AnimatedWave, StaticCircle, StaticPoint
from models import LaserPoint, Blank, StaticLine, StaticWave, Effect, AnimatedWave, StaticCircle, StaticPoint, StaticStars
import logging
import configparser
import time
Expand Down Expand Up @@ -139,7 +139,8 @@ def setup():
StaticWave(0), # Blue static wave
AnimatedWave(0), # Blue animated wave
StaticCircle(int(global_data.config['laser_output']['height'])/2, int(global_data.config['laser_output']['width'])/2, int(global_data.config['laser_output']['height'])/5, 0, 255, 0, 0), # Green static circle
StaticPoint(laser_point5,0)
StaticPoint(laser_point5,0),
StaticStars() # white stars
]

setup()

0 comments on commit 6cd2d68

Please sign in to comment.