|
import streamlit as st |
|
import matplotlib.pyplot as plt |
|
import numpy as np |
|
|
|
def generate_colored_circle_template(num_circles): |
|
fig, ax = plt.subplots(figsize=(6, 6)) |
|
ax.set_xlim(0, 1) |
|
ax.set_ylim(0, 1) |
|
ax.axis('off') |
|
|
|
for _ in range(num_circles): |
|
radius = np.random.uniform(0.05, 0.15) |
|
center = (np.random.uniform(radius, 1-radius), np.random.uniform(radius, 1-radius)) |
|
color = np.random.rand(3,) |
|
circle = plt.Circle(center, radius, color=color, alpha=0.8) |
|
ax.add_artist(circle) |
|
return fig |
|
|
|
def generate_symmetrical_circle_layout(num_layers): |
|
fig, ax = plt.subplots(figsize=(6, 6)) |
|
ax.set_aspect('equal') |
|
ax.axis('off') |
|
|
|
center = (0.5, 0.5) |
|
for i in range(num_layers): |
|
radius = (i + 1) * 0.1 |
|
for j in range(6): |
|
angle = np.pi / 3 * j |
|
x = center[0] + radius * np.cos(angle) |
|
y = center[1] + radius * np.sin(angle) |
|
circle = plt.Circle((x, y), radius=0.05, color=np.random.rand(3,), fill=True) |
|
ax.add_artist(circle) |
|
return fig |
|
|
|
|
|
st.title("Circle Packings Visualization") |
|
|
|
mode = st.radio("Choose a visualization mode:", ("Random Circle Packings", "Symmetrical Circle Layouts")) |
|
|
|
if mode == "Random Circle Packings": |
|
num_circles = st.slider("Number of Circles", 5, 50, 10) |
|
fig = generate_colored_circle_template(num_circles) |
|
st.pyplot(fig) |
|
elif mode == "Symmetrical Circle Layouts": |
|
num_layers = st.slider("Number of Symmetrical Layers", 1, 5, 3) |
|
fig = generate_symmetrical_circle_layout(num_layers) |
|
st.pyplot(fig) |
|
|