Skip to content

Commit

Permalink
Merge pull request #32 from goodtimes-code/newideas
Browse files Browse the repository at this point in the history
Bugfixes for stars laser object
  • Loading branch information
goodtimes-code committed Feb 1, 2024
2 parents 6cb5a5c + b429aa8 commit b3f8a16
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 3 additions & 1 deletion osc-receiver/laser_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def update_screen(self):
laser_point_output.x =laser_point_output.x * float(global_data.config['laser_preview']['screen_scale_factor'])
laser_point_output.y =laser_point_output.y * float(global_data.config['laser_preview']['screen_scale_factor'])

pg.draw.circle(self.screen, (laser_point_output.r, laser_point_output.g, laser_point_output.b) , (laser_point_output.x, laser_point_output.y), self.LASER_POINT_SIZE)
if not laser_point.is_blank():
pg.draw.circle(self.screen, (laser_point_output.r, laser_point_output.g, laser_point_output.b) , (laser_point_output.x, laser_point_output.y), self.LASER_POINT_SIZE)

if previous_laser_point_output and not laser_point.is_blank():
pg.draw.line(self.screen, (laser_point_output.r, laser_point_output.g, laser_point_output.b), (previous_laser_point_output.x, previous_laser_point_output.y), (laser_point_output.x, laser_point_output.y), self.LASER_POINT_SIZE)
previous_laser_point_output = laser_point_output
Expand Down
14 changes: 10 additions & 4 deletions osc-receiver/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ 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.star_count = global_data.parameters.get('stars_amount', 8) # Default to 50 stars if not specified
self.generate_stars()

def generate_stars(self):
Expand All @@ -218,14 +218,20 @@ def generate_stars(self):
# 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']))
# 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)

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)
#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']:
Expand Down
7 changes: 4 additions & 3 deletions osc-receiver/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ def apply_effects_to_laser_points(visible_laser_object):
shifted_points.append(shifted_point)

# Apply color change if necessary
if color_r: shifted_point.r = color_r
if color_g: shifted_point.g = color_g
if color_b: shifted_point.b = color_b
if not laser_point.is_blank():
if color_r: shifted_point.r = color_r
if color_g: shifted_point.g = color_g
if color_b: shifted_point.b = color_b

total_x, total_y = sum(p.x for p in shifted_points), sum(p.y for p in shifted_points)
center_x, center_y = calculate_geometric_center(shifted_points)
Expand Down

0 comments on commit b3f8a16

Please sign in to comment.