Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +1 -55
src/streamlit_app.py
CHANGED
|
@@ -314,7 +314,7 @@ def main():
|
|
| 314 |
# Enhanced angle input with unique keys
|
| 315 |
angle_input_method = st.sidebar.radio(
|
| 316 |
"Choose angle input method:",
|
| 317 |
-
["Slider", "Text Input", "Common Angles"
|
| 318 |
key="angle_input_method_radio"
|
| 319 |
)
|
| 320 |
|
|
@@ -337,60 +337,6 @@ def main():
|
|
| 337 |
angle_rad = st.sidebar.number_input("Angle (radians)", value=pi/4, step=0.1, min_value=0.0, max_value=2*pi, key="angle_radians_input")
|
| 338 |
angle = degrees(angle_rad)
|
| 339 |
|
| 340 |
-
elif angle_input_method == "Auto Animation":
|
| 341 |
-
speed = st.sidebar.slider("Animation Speed", 1, 10, 5, key="animation_speed_slider")
|
| 342 |
-
angle_step = st.sidebar.slider("Angle Step", 5, 30, 15, key="animation_step_slider")
|
| 343 |
-
|
| 344 |
-
# Add animation controls
|
| 345 |
-
col_anim1, col_anim2, col_anim3 = st.sidebar.columns(3)
|
| 346 |
-
with col_anim1:
|
| 347 |
-
start_animation = st.sidebar.button("▶️ Start", key="start_anim_button")
|
| 348 |
-
with col_anim2:
|
| 349 |
-
stop_animation = st.sidebar.button("⏹️ Stop", key="stop_anim_button")
|
| 350 |
-
with col_anim3:
|
| 351 |
-
reset_animation = st.sidebar.button("🔄 Reset", key="reset_anim_button")
|
| 352 |
-
|
| 353 |
-
# Initialize session state
|
| 354 |
-
if 'animation_running' not in st.session_state:
|
| 355 |
-
st.session_state.animation_running = False
|
| 356 |
-
if 'current_animation_angle' not in st.session_state:
|
| 357 |
-
st.session_state.current_animation_angle = 0
|
| 358 |
-
if 'animation_counter' not in st.session_state:
|
| 359 |
-
st.session_state.animation_counter = 0
|
| 360 |
-
|
| 361 |
-
if start_animation:
|
| 362 |
-
st.session_state.animation_running = True
|
| 363 |
-
if stop_animation:
|
| 364 |
-
st.session_state.animation_running = False
|
| 365 |
-
if reset_animation:
|
| 366 |
-
st.session_state.current_animation_angle = 0
|
| 367 |
-
st.session_state.animation_running = False
|
| 368 |
-
st.session_state.animation_counter = 0
|
| 369 |
-
|
| 370 |
-
# Simplified animation using counter-based approach
|
| 371 |
-
if st.session_state.animation_running:
|
| 372 |
-
st.session_state.animation_counter += 1
|
| 373 |
-
|
| 374 |
-
# Update angle based on counter and speed
|
| 375 |
-
if st.session_state.animation_counter % (11 - speed) == 0: # Speed control
|
| 376 |
-
st.session_state.current_animation_angle += angle_step
|
| 377 |
-
if st.session_state.current_animation_angle >= 360:
|
| 378 |
-
st.session_state.current_animation_angle = 0
|
| 379 |
-
st.session_state.animation_running = False
|
| 380 |
-
st.success("🎉 Animation complete!")
|
| 381 |
-
st.session_state.animation_counter = 0
|
| 382 |
-
|
| 383 |
-
# Auto-refresh
|
| 384 |
-
st.rerun()
|
| 385 |
-
|
| 386 |
-
angle = st.session_state.current_animation_angle
|
| 387 |
-
|
| 388 |
-
# Show animation status
|
| 389 |
-
if st.session_state.animation_running:
|
| 390 |
-
st.sidebar.success(f"🎬 Animating: {angle}°")
|
| 391 |
-
else:
|
| 392 |
-
st.sidebar.info(f"⏸️ Stopped at: {angle}°")
|
| 393 |
-
|
| 394 |
else: # Common Angles
|
| 395 |
common_angles = {
|
| 396 |
"0°": 0, "30°": 30, "45°": 45, "60°": 60, "90°": 90,
|
|
|
|
| 314 |
# Enhanced angle input with unique keys
|
| 315 |
angle_input_method = st.sidebar.radio(
|
| 316 |
"Choose angle input method:",
|
| 317 |
+
["Slider", "Text Input", "Common Angles"],
|
| 318 |
key="angle_input_method_radio"
|
| 319 |
)
|
| 320 |
|
|
|
|
| 337 |
angle_rad = st.sidebar.number_input("Angle (radians)", value=pi/4, step=0.1, min_value=0.0, max_value=2*pi, key="angle_radians_input")
|
| 338 |
angle = degrees(angle_rad)
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
else: # Common Angles
|
| 341 |
common_angles = {
|
| 342 |
"0°": 0, "30°": 30, "45°": 45, "60°": 60, "90°": 90,
|