import matplotlib.pyplot as plt | |
import gradio as gr | |
def isprime(x): | |
if x < 2: | |
return False | |
for i in range(2, x): | |
if x % i == 0: | |
return False | |
return True | |
def stars(n): | |
plt.figure(figsize=(20,20), facecolor=(0.5, 0.5, 0.5)) | |
for i, j in zip(range(1,n), range(n, 1, -1)): | |
plt.plot([0, i], [j, 0], "k", linewidth=1) | |
plt.plot([0, -i], [j, 0], "w", linewidth=1) | |
plt.plot([0, i], [-j, 0], "w", linewidth=1) | |
plt.plot([0, -i], [-j, 0], "k", linewidth=1) | |
plt.axis('off') | |
return plt.gcf() | |
iface = gr.Interface(stars, gr.inputs.Slider(1, 100, 1), "plot") | |
iface.launch() | |
# n = 50 | |
# plt.figure(figsize=(20,20), facecolor=(0.5, 0.5, 0.5)) | |
# for i, j in zip(range(1,n), range(n, 1, -1)): | |
# zi = i / (2**(1/2)) | |
# zj = j / (2**(1/2)) | |
# plt.plot([zi, 0], [zi, j], "k", linewidth=1) | |
# plt.plot([zi, j], [zi, 0], "w", linewidth=1) | |
# plt.plot([-zi, 0], [zi, j], "w", linewidth=1) | |
# plt.plot([-zi, -j], [zi, 0], "k", linewidth=1) | |
# plt.plot([zi, 0], [-zi, -j], "w", linewidth=1) | |
# plt.plot([zi, j], [-zi, 0], "k", linewidth=1) | |
# plt.plot([-zi, 0], [-zi, -j], "k", linewidth=1) | |
# plt.plot([-zi, -j], [-zi, 0], "w", linewidth=1) | |
# plt.axis('off') |