dcoste commited on
Commit
9ea7d32
1 Parent(s): bb8c904
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -6,8 +6,8 @@ import streamlit as st
6
  import os
7
  import time
8
 
9
- os.system("pip install -r requirements.txt")
10
- os.system("pip install --upgrade pip")
11
  BG_COLOR = (0, 0, 0)
12
  fullscreen = True
13
 
@@ -30,15 +30,24 @@ y = randint(0, screen_height - img_size[1])
30
  x_speed = 2
31
  y_speed = 3
32
 
33
- dvd_background_color = [255, 255, 255]
 
 
 
 
 
 
 
 
 
34
 
35
 
36
  def random_color_change(surface, color_to_be_changed):
37
  np_surface = pygame.surfarray.array3d(surface)
38
  for channel in range(np_surface.shape[-1]):
39
- random_channel_color = randint(60, 255)
40
  np_surface[:, :, channel] = np.where(
41
- np.logical_and(np_surface[:, :, channel] >= color_to_be_changed[channel] - 40,
42
  np_surface[:, :, channel] <= color_to_be_changed[channel]),
43
  random_channel_color, np_surface[:, :, channel])
44
  color_to_be_changed[channel] = random_channel_color
@@ -52,13 +61,13 @@ while True:
52
 
53
  if ((x + img_size[1] + x_speed >= screen_width) or (x + x_speed <= 0)) and \
54
  ((y + y_speed + img_size[0] >= screen_height) or (y + y_speed <= 0)):
55
- x -= int(4.5 * x_speed)
56
- y -= int(3.5 * y_speed)
57
  if (x + img_size[0] >= screen_height) or (x <= 0):
58
- logo, dvd_background_color = random_color_change(logo, dvd_background_color)
59
  x_speed = -x_speed
60
  if (y + img_size[1] >= screen_width) or (y <= 0):
61
- logo, dvd_background_color = random_color_change(logo, dvd_background_color)
62
  y_speed = -y_speed
63
 
64
  x += x_speed
 
6
  import os
7
  import time
8
 
9
+ # os.system("pip install -r requirements.txt")
10
+ # os.system("pip install --upgrade pip")
11
  BG_COLOR = (0, 0, 0)
12
  fullscreen = True
13
 
 
30
  x_speed = 2
31
  y_speed = 3
32
 
33
+
34
+
35
+ np_logo = pygame.surfarray.array3d(logo)
36
+
37
+ # Inverse the colors so that the background of the DVD logo is black and the letters are white
38
+ np_logo = np.where(np_logo >= 200, 0, np_logo+200)
39
+
40
+ dvd_letters_color = [255, 255, 255]
41
+ dvd_background_color = [0, 0, 0]
42
+ logo = pygame.surfarray.make_surface(np_logo)
43
 
44
 
45
  def random_color_change(surface, color_to_be_changed):
46
  np_surface = pygame.surfarray.array3d(surface)
47
  for channel in range(np_surface.shape[-1]):
48
+ random_channel_color = randint(30, 240)
49
  np_surface[:, :, channel] = np.where(
50
+ np.logical_and(np_surface[:, :, channel] >= color_to_be_changed[channel]-20,
51
  np_surface[:, :, channel] <= color_to_be_changed[channel]),
52
  random_channel_color, np_surface[:, :, channel])
53
  color_to_be_changed[channel] = random_channel_color
 
61
 
62
  if ((x + img_size[1] + x_speed >= screen_width) or (x + x_speed <= 0)) and \
63
  ((y + y_speed + img_size[0] >= screen_height) or (y + y_speed <= 0)):
64
+ x -= int(4.5 * x_speed + 7)
65
+ y -= int(3.5 * y_speed + 7)
66
  if (x + img_size[0] >= screen_height) or (x <= 0):
67
+ logo, dvd_letters_color = random_color_change(logo, dvd_letters_color)
68
  x_speed = -x_speed
69
  if (y + img_size[1] >= screen_width) or (y <= 0):
70
+ logo, dvd_letters_color = random_color_change(logo, dvd_letters_color)
71
  y_speed = -y_speed
72
 
73
  x += x_speed