awacke1 commited on
Commit
5a34697
·
verified ·
1 Parent(s): 68599bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -17
app.py CHANGED
@@ -5,6 +5,7 @@ import matplotlib.colors as mcolors
5
 
6
  # Global constant for golden ratio
7
  golden_ratio = (1 + np.sqrt(5)) / 2
 
8
 
9
  def is_prime(n):
10
  """Check if a number is prime."""
@@ -23,43 +24,51 @@ def fib_sequence(n):
23
  return fib_seq[2:] # Exclude first two numbers for this use case
24
 
25
  def adjust_color_brightness(color, factor):
26
- """Darken a color by a given factor."""
27
- color = np.array(mcolors.to_rgb(color)) * factor
28
- return tuple(color)
29
 
30
  def generate_colored_circle_template(num_circles):
 
31
  fig, ax = plt.subplots(figsize=(6, 6))
32
  ax.set_xlim(0, 1)
33
  ax.set_ylim(0, 1)
34
  ax.axis('off')
35
 
36
  for i in range(num_circles):
37
- radius = np.random.uniform(0.05, 0.15)
38
- center = (np.random.uniform(radius, 1-radius), np.random.uniform(radius, 1-radius))
39
- base_color = np.random.rand(3,)
40
- darker_color = adjust_color_brightness(base_color, 0.5)
41
- color_variation = base_color * (0.95 + 0.1 * np.random.rand()) # Slight color variation
42
- circle = plt.Circle(center, radius, color=color_variation, ec=darker_color, lw=1, alpha=0.5)
 
 
43
  ax.add_artist(circle)
44
  return fig
45
 
46
  def generate_symmetrical_circle_layout(num_layers):
 
47
  fig, ax = plt.subplots(figsize=(6, 6))
48
  ax.set_aspect('equal')
49
  ax.axis('off')
50
-
 
51
  center = (0.5, 0.5)
52
- for i in range(num_layers):
53
- radius = (i + 1) * 0.1
54
- for j in range(6):
55
- angle = np.pi / 3 * j
 
 
56
  x = center[0] + radius * np.cos(angle)
57
  y = center[1] + radius * np.sin(angle)
58
- circle = plt.Circle((x, y), radius=0.05, color=np.random.rand(3,), fill=True)
 
59
  ax.add_artist(circle)
60
  return fig
61
 
62
  def generate_fibonacci_spiral_layout(num_points):
 
63
  fig, ax = plt.subplots(figsize=(6, 6))
64
  ax.axis('off')
65
  radius = 0.05
@@ -68,12 +77,14 @@ def generate_fibonacci_spiral_layout(num_points):
68
  distance = np.sqrt(i) * radius
69
  x = 0.5 + distance * np.cos(angle)
70
  y = 0.5 + distance * np.sin(angle)
71
- circle = plt.Circle((x, y), radius, color=np.random.rand(3,), fill=True)
 
72
  ax.add_artist(circle)
73
  ax.set_aspect('equal')
74
  return fig
75
 
76
  def generate_prime_number_spiral(num_points):
 
77
  fig, ax = plt.subplots(figsize=(6, 6))
78
  ax.axis('off')
79
  radius = 0.05
@@ -83,12 +94,14 @@ def generate_prime_number_spiral(num_points):
83
  distance = np.sqrt(i) * radius
84
  x = 0.5 + distance * np.cos(angle)
85
  y = 0.5 + distance * np.sin(angle)
86
- circle = plt.Circle((x, y), radius, color=np.random.rand(3,), fill=True)
 
87
  ax.add_artist(circle)
88
  ax.set_aspect('equal')
89
  return fig
90
 
91
  def emoji_dynamics_and_number_theory_simulation(size):
 
92
  fib_seq = fib_sequence(size**2)
93
  grid = []
94
 
 
5
 
6
  # Global constant for golden ratio
7
  golden_ratio = (1 + np.sqrt(5)) / 2
8
+ color_wheel = plt.get_cmap('hsv') # Use the HSV color wheel for harmonious colors
9
 
10
  def is_prime(n):
11
  """Check if a number is prime."""
 
24
  return fib_seq[2:] # Exclude first two numbers for this use case
25
 
26
  def adjust_color_brightness(color, factor):
27
+ """Adjust the brightness of a color."""
28
+ return tuple(np.array(mcolors.to_rgb(color)) * factor)
 
29
 
30
  def generate_colored_circle_template(num_circles):
31
+ """Improved use of color and symmetry in circle generation."""
32
  fig, ax = plt.subplots(figsize=(6, 6))
33
  ax.set_xlim(0, 1)
34
  ax.set_ylim(0, 1)
35
  ax.axis('off')
36
 
37
  for i in range(num_circles):
38
+ radius = np.random.uniform(0.05, 0.1)
39
+ angle = 2 * np.pi * i / num_circles
40
+ distance = np.sqrt(np.random.uniform(0.1, 0.9))
41
+ x = 0.5 + distance * np.cos(angle)
42
+ y = 0.5 + distance * np.sin(angle)
43
+ color = color_wheel(i / num_circles)
44
+ alpha = 0.6 + 0.4 * (1 - distance) # More transparent further out
45
+ circle = plt.Circle((x, y), radius, color=color, alpha=alpha)
46
  ax.add_artist(circle)
47
  return fig
48
 
49
  def generate_symmetrical_circle_layout(num_layers):
50
+ """Generate a more symmetrical circle layout."""
51
  fig, ax = plt.subplots(figsize=(6, 6))
52
  ax.set_aspect('equal')
53
  ax.axis('off')
54
+
55
+ max_radius = 0.1 + 0.15 * (num_layers - 1) # Adjust so outer circles don't overlap the figure boundary
56
  center = (0.5, 0.5)
57
+
58
+ for layer in range(num_layers):
59
+ radius = 0.05 + layer * 0.1
60
+ num_circles = layer * 6 if layer > 0 else 1 # Increase circles in outer layers
61
+ for i in range(num_circles):
62
+ angle = 2 * np.pi * i / num_circles
63
  x = center[0] + radius * np.cos(angle)
64
  y = center[1] + radius * np.sin(angle)
65
+ color = color_wheel(i / num_circles)
66
+ circle = plt.Circle((x, y), max_radius / num_layers, color=color, alpha=0.5 + 0.5 * (1 - layer / num_layers))
67
  ax.add_artist(circle)
68
  return fig
69
 
70
  def generate_fibonacci_spiral_layout(num_points):
71
+ """Generate layout based on Fibonacci spiral."""
72
  fig, ax = plt.subplots(figsize=(6, 6))
73
  ax.axis('off')
74
  radius = 0.05
 
77
  distance = np.sqrt(i) * radius
78
  x = 0.5 + distance * np.cos(angle)
79
  y = 0.5 + distance * np.sin(angle)
80
+ color = color_wheel(i / num_points)
81
+ circle = plt.Circle((x, y), radius, color=color, fill=True, alpha=0.8)
82
  ax.add_artist(circle)
83
  ax.set_aspect('equal')
84
  return fig
85
 
86
  def generate_prime_number_spiral(num_points):
87
+ """Generate spiral layout highlighting prime numbers."""
88
  fig, ax = plt.subplots(figsize=(6, 6))
89
  ax.axis('off')
90
  radius = 0.05
 
94
  distance = np.sqrt(i) * radius
95
  x = 0.5 + distance * np.cos(angle)
96
  y = 0.5 + distance * np.sin(angle)
97
+ color = color_wheel(i / num_points)
98
+ circle = plt.Circle((x, y), radius, color=color, fill=True, alpha=0.8)
99
  ax.add_artist(circle)
100
  ax.set_aspect('equal')
101
  return fig
102
 
103
  def emoji_dynamics_and_number_theory_simulation(size):
104
+ """Simulate emoji dynamics based on number theory."""
105
  fib_seq = fib_sequence(size**2)
106
  grid = []
107