Commit
•
d2caef5
1
Parent(s):
7005a2c
Update app.py
Browse files
app.py
CHANGED
@@ -5,25 +5,18 @@ import numpy as np
|
|
5 |
def main():
|
6 |
st.title("Generador de Sello con Streamlit")
|
7 |
|
8 |
-
# Definir las medidas del sello y la geometría sagrada
|
9 |
radius_outer = 1.0
|
10 |
radius_inner = 0.6
|
11 |
circle_center = (0.0, 0.0)
|
12 |
|
13 |
-
# Crear un arreglo de ángulos para dibujar la circunferencia
|
14 |
theta = np.linspace(0, 2 * np.pi, 100)
|
15 |
-
|
16 |
-
# Calcular las coordenadas de los puntos en la circunferencia exterior e interior
|
17 |
x_outer = circle_center[0] + radius_outer * np.cos(theta)
|
18 |
y_outer = circle_center[1] + radius_outer * np.sin(theta)
|
19 |
-
|
20 |
x_inner = circle_center[0] + radius_inner * np.cos(theta)
|
21 |
y_inner = circle_center[1] + radius_inner * np.sin(theta)
|
22 |
|
23 |
-
# Pedir al usuario un nombre
|
24 |
name = st.text_input("Ingrese su nombre:")
|
25 |
|
26 |
-
# Solicitar al usuario que elija la conversión: hebreo o árabe
|
27 |
conversion_type = st.selectbox("Elija la conversión:", ["Hebreo", "Árabe"])
|
28 |
|
29 |
conversion_dict = {}
|
@@ -32,13 +25,59 @@ def main():
|
|
32 |
conversion_dict = {
|
33 |
'A': ('א', 1),
|
34 |
'B': ('ב', 2),
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
else:
|
38 |
conversion_dict = {
|
39 |
'A': ('أ', 1),
|
40 |
'B': ('ب', 2),
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
|
44 |
converted_name = ""
|
@@ -57,32 +96,25 @@ def main():
|
|
57 |
|
58 |
st.write("Nombre convertido:", converted_name)
|
59 |
|
60 |
-
# Crear una figura y dibujar los elementos
|
61 |
fig, ax = plt.subplots(figsize=(6, 6))
|
62 |
-
|
63 |
-
# Dibujar el relleno entre los círculos
|
64 |
ax.fill_between(theta, radius_inner, radius_outer, color='white')
|
65 |
|
66 |
-
# Agregar el nombre convertido en la figura
|
67 |
angle = np.linspace(0, 2 * np.pi, len(converted_name), endpoint=False)
|
68 |
for char, ang in zip(converted_name, angle):
|
69 |
x = circle_center[0] + (radius_inner + (radius_outer - radius_inner) / 2) * np.cos(ang)
|
70 |
y = circle_center[1] + (radius_inner + (radius_outer - radius_inner) / 2) * np.sin(ang)
|
71 |
ax.text(x, y, char, fontsize=34, ha='center', va='center', rotation=ang * 180 / np.pi + 90)
|
72 |
|
73 |
-
# Dibujar las circunferencias exterior e interior
|
74 |
ax.plot(x_outer, y_outer, color='black')
|
75 |
ax.plot(x_inner, y_inner, color='black')
|
76 |
|
77 |
-
# Generar una figura aleatoria en el centro del círculo interno
|
78 |
figure_points = []
|
79 |
num_sides = len(numerical_values)
|
80 |
|
81 |
-
# Verificar que num_sides no sea cero
|
82 |
if num_sides != 0:
|
83 |
angle_step = 2 * np.pi / num_sides
|
84 |
random_angles = np.random.rand(num_sides) * 2 * np.pi
|
85 |
-
polygon_angles = []
|
86 |
|
87 |
for i, angle in enumerate(random_angles):
|
88 |
value = numerical_values[i % len(numerical_values)]
|
@@ -92,40 +124,31 @@ def main():
|
|
92 |
x = circle_center[0] + max_radius * np.cos(angle)
|
93 |
y = circle_center[1] + max_radius * np.sin(angle)
|
94 |
figure_points.append((x, y))
|
95 |
-
ax.plot([x, circle_center[0]], [y, circle_center[1]], color='white')
|
96 |
-
polygon_angles.append(angle)
|
97 |
|
98 |
-
# Conectar todas las puntas de la figura aleatoria con líneas
|
99 |
for i in range(num_sides):
|
100 |
x1, y1 = figure_points[i]
|
101 |
for j in range(i + 1, num_sides):
|
102 |
x2, y2 = figure_points[j]
|
103 |
ax.plot([x1, x2], [y1, y2], color='white')
|
104 |
|
105 |
-
# Crear el polígono con los ángulos generados
|
106 |
polygon_points = []
|
107 |
for angle in polygon_angles:
|
108 |
x = circle_center[0] + radius_inner * np.cos(angle)
|
109 |
y = circle_center[1] + radius_inner * np.sin(angle)
|
110 |
polygon_points.append((x, y))
|
111 |
|
112 |
-
# Conectar todas las puntas del polígono con líneas
|
113 |
for i in range(num_sides):
|
114 |
x1, y1 = polygon_points[i]
|
115 |
x2, y2 = polygon_points[(i + 1) % num_sides]
|
116 |
ax.plot([x1, x2], [y1, y2], color='black')
|
117 |
|
118 |
-
# Ajustar los límites de los ejes para que el sello sea visible correctamente
|
119 |
ax.set_xlim(-1.2, 1.2)
|
120 |
ax.set_ylim(-1.2, 1.2)
|
121 |
-
|
122 |
-
# Eliminar los ejes y etiquetas para obtener un diseño limpio
|
123 |
ax.axis('off')
|
124 |
|
125 |
-
# Guardar la figura como archivo de imagen en formato .jpg
|
126 |
plt.savefig('sello.jpg', format='jpg')
|
127 |
-
|
128 |
-
# Mostrar la imagen en Streamlit
|
129 |
st.image('sello.jpg')
|
130 |
|
131 |
if __name__ == '__main__':
|
|
|
5 |
def main():
|
6 |
st.title("Generador de Sello con Streamlit")
|
7 |
|
|
|
8 |
radius_outer = 1.0
|
9 |
radius_inner = 0.6
|
10 |
circle_center = (0.0, 0.0)
|
11 |
|
|
|
12 |
theta = np.linspace(0, 2 * np.pi, 100)
|
|
|
|
|
13 |
x_outer = circle_center[0] + radius_outer * np.cos(theta)
|
14 |
y_outer = circle_center[1] + radius_outer * np.sin(theta)
|
|
|
15 |
x_inner = circle_center[0] + radius_inner * np.cos(theta)
|
16 |
y_inner = circle_center[1] + radius_inner * np.sin(theta)
|
17 |
|
|
|
18 |
name = st.text_input("Ingrese su nombre:")
|
19 |
|
|
|
20 |
conversion_type = st.selectbox("Elija la conversión:", ["Hebreo", "Árabe"])
|
21 |
|
22 |
conversion_dict = {}
|
|
|
25 |
conversion_dict = {
|
26 |
'A': ('א', 1),
|
27 |
'B': ('ב', 2),
|
28 |
+
'C': ('ג', 3),
|
29 |
+
'D': ('ד', 4),
|
30 |
+
'E': ('ה', 5),
|
31 |
+
'F': ('ו', 6),
|
32 |
+
'G': ('ז', 7),
|
33 |
+
'H': ('ח', 8),
|
34 |
+
'I': ('ט', 9),
|
35 |
+
'J': ('י', 10),
|
36 |
+
'K': ('כ', 20),
|
37 |
+
'L': ('ל', 30),
|
38 |
+
'M': ('מ', 40),
|
39 |
+
'N': ('נ', 50),
|
40 |
+
'O': ('ס', 60),
|
41 |
+
'P': ('ע', 70),
|
42 |
+
'Q': ('פ', 80),
|
43 |
+
'R': ('צ', 90),
|
44 |
+
'S': ('ק', 100),
|
45 |
+
'T': ('ר', 200),
|
46 |
+
'U': ('ש', 300),
|
47 |
+
'V': ('ת', 400),
|
48 |
+
'W': ('ך', 500),
|
49 |
+
'X': ('ם', 600),
|
50 |
+
'Y': ('ן', 700),
|
51 |
+
'Z': ('ף', 800),
|
52 |
}
|
53 |
else:
|
54 |
conversion_dict = {
|
55 |
'A': ('أ', 1),
|
56 |
'B': ('ب', 2),
|
57 |
+
'C': ('ج', 3),
|
58 |
+
'D': ('د', 4),
|
59 |
+
'E': ('ه', 5),
|
60 |
+
'F': ('و', 6),
|
61 |
+
'G': ('ز', 7),
|
62 |
+
'H': ('ح', 8),
|
63 |
+
'I': ('ط', 9),
|
64 |
+
'J': ('ي', 10),
|
65 |
+
'K': ('ك', 20),
|
66 |
+
'L': ('ل', 30),
|
67 |
+
'M': ('م', 40),
|
68 |
+
'N': ('ن', 50),
|
69 |
+
'O': ('س', 60),
|
70 |
+
'P': ('ع', 70),
|
71 |
+
'Q': ('ف', 80),
|
72 |
+
'R': ('ص', 90),
|
73 |
+
'S': ('ق', 100),
|
74 |
+
'T': ('ر', 200),
|
75 |
+
'U': ('ش', 300),
|
76 |
+
'V': ('ت', 400),
|
77 |
+
'W': ('خ', 500),
|
78 |
+
'X': ('م', 600),
|
79 |
+
'Y': ('ن', 700),
|
80 |
+
'Z': ('ظ', 800),
|
81 |
}
|
82 |
|
83 |
converted_name = ""
|
|
|
96 |
|
97 |
st.write("Nombre convertido:", converted_name)
|
98 |
|
|
|
99 |
fig, ax = plt.subplots(figsize=(6, 6))
|
|
|
|
|
100 |
ax.fill_between(theta, radius_inner, radius_outer, color='white')
|
101 |
|
|
|
102 |
angle = np.linspace(0, 2 * np.pi, len(converted_name), endpoint=False)
|
103 |
for char, ang in zip(converted_name, angle):
|
104 |
x = circle_center[0] + (radius_inner + (radius_outer - radius_inner) / 2) * np.cos(ang)
|
105 |
y = circle_center[1] + (radius_inner + (radius_outer - radius_inner) / 2) * np.sin(ang)
|
106 |
ax.text(x, y, char, fontsize=34, ha='center', va='center', rotation=ang * 180 / np.pi + 90)
|
107 |
|
|
|
108 |
ax.plot(x_outer, y_outer, color='black')
|
109 |
ax.plot(x_inner, y_inner, color='black')
|
110 |
|
|
|
111 |
figure_points = []
|
112 |
num_sides = len(numerical_values)
|
113 |
|
|
|
114 |
if num_sides != 0:
|
115 |
angle_step = 2 * np.pi / num_sides
|
116 |
random_angles = np.random.rand(num_sides) * 2 * np.pi
|
117 |
+
polygon_angles = []
|
118 |
|
119 |
for i, angle in enumerate(random_angles):
|
120 |
value = numerical_values[i % len(numerical_values)]
|
|
|
124 |
x = circle_center[0] + max_radius * np.cos(angle)
|
125 |
y = circle_center[1] + max_radius * np.sin(angle)
|
126 |
figure_points.append((x, y))
|
127 |
+
ax.plot([x, circle_center[0]], [y, circle_center[1]], color='white')
|
128 |
+
polygon_angles.append(angle)
|
129 |
|
|
|
130 |
for i in range(num_sides):
|
131 |
x1, y1 = figure_points[i]
|
132 |
for j in range(i + 1, num_sides):
|
133 |
x2, y2 = figure_points[j]
|
134 |
ax.plot([x1, x2], [y1, y2], color='white')
|
135 |
|
|
|
136 |
polygon_points = []
|
137 |
for angle in polygon_angles:
|
138 |
x = circle_center[0] + radius_inner * np.cos(angle)
|
139 |
y = circle_center[1] + radius_inner * np.sin(angle)
|
140 |
polygon_points.append((x, y))
|
141 |
|
|
|
142 |
for i in range(num_sides):
|
143 |
x1, y1 = polygon_points[i]
|
144 |
x2, y2 = polygon_points[(i + 1) % num_sides]
|
145 |
ax.plot([x1, x2], [y1, y2], color='black')
|
146 |
|
|
|
147 |
ax.set_xlim(-1.2, 1.2)
|
148 |
ax.set_ylim(-1.2, 1.2)
|
|
|
|
|
149 |
ax.axis('off')
|
150 |
|
|
|
151 |
plt.savefig('sello.jpg', format='jpg')
|
|
|
|
|
152 |
st.image('sello.jpg')
|
153 |
|
154 |
if __name__ == '__main__':
|