SHAMIL SHAHBAZ AWAN
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
# Define gravity constants for each planet as a percentage of Earth's gravity
|
|
@@ -39,51 +40,13 @@ def main():
|
|
| 39 |
min-height: 100vh;
|
| 40 |
}
|
| 41 |
.gradio-container .output-box {
|
| 42 |
-
animation: fadein 2s ease-in-out
|
| 43 |
}
|
| 44 |
-
|
| 45 |
@keyframes fadein {
|
| 46 |
from { opacity: 0; }
|
| 47 |
to { opacity: 1; }
|
| 48 |
}
|
| 49 |
-
|
| 50 |
-
@keyframes scaleup {
|
| 51 |
-
from { transform: scale(0.8); }
|
| 52 |
-
to { transform: scale(1); }
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
@keyframes textcolor {
|
| 56 |
-
0% { color: #ff7e5f; }
|
| 57 |
-
50% { color: #feb47b; }
|
| 58 |
-
100% { color: #00b4d8; }
|
| 59 |
-
}
|
| 60 |
-
|
| 61 |
-
/* Balloon Animation */
|
| 62 |
-
.balloon {
|
| 63 |
-
position: absolute;
|
| 64 |
-
bottom: 0;
|
| 65 |
-
animation: rise 6s ease-in-out forwards, float 4s ease-in-out infinite;
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
@keyframes rise {
|
| 69 |
-
0% { bottom: 0; opacity: 1; }
|
| 70 |
-
100% { bottom: 90%; opacity: 0; }
|
| 71 |
-
}
|
| 72 |
-
|
| 73 |
-
@keyframes float {
|
| 74 |
-
0% { transform: translateX(0); }
|
| 75 |
-
50% { transform: translateX(30px); }
|
| 76 |
-
100% { transform: translateX(0); }
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
.balloon-text {
|
| 80 |
-
font-size: 1.5rem;
|
| 81 |
-
color: white;
|
| 82 |
-
text-align: center;
|
| 83 |
-
font-weight: bold;
|
| 84 |
-
}
|
| 85 |
""") as demo:
|
| 86 |
-
|
| 87 |
gr.Markdown("# Weight Calculator on Different Planets")
|
| 88 |
gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")
|
| 89 |
|
|
@@ -93,35 +56,9 @@ def main():
|
|
| 93 |
|
| 94 |
output = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)
|
| 95 |
|
| 96 |
-
# HTML component for balloon effect trigger
|
| 97 |
-
balloon_script = gr.HTML("""
|
| 98 |
-
<script>
|
| 99 |
-
function triggerBalloonEffect() {
|
| 100 |
-
const balloonCount = 5; // Number of balloons to show
|
| 101 |
-
for (let i = 0; i < balloonCount; i++) {
|
| 102 |
-
let balloon = document.createElement('div');
|
| 103 |
-
balloon.classList.add('balloon');
|
| 104 |
-
balloon.style.left = Math.random() * 100 + 'vw'; // Random horizontal position
|
| 105 |
-
let balloonText = document.createElement('div');
|
| 106 |
-
balloonText.classList.add('balloon-text');
|
| 107 |
-
balloonText.textContent = '🎈'; // Emoji or custom text for the balloon
|
| 108 |
-
balloon.appendChild(balloonText);
|
| 109 |
-
document.body.appendChild(balloon);
|
| 110 |
-
setTimeout(() => balloon.remove(), 6000); // Remove balloon after animation
|
| 111 |
-
}
|
| 112 |
-
}
|
| 113 |
-
</script>
|
| 114 |
-
""")
|
| 115 |
-
|
| 116 |
-
# Function to trigger balloon effect
|
| 117 |
-
def trigger_balloon_and_weight(earth_weight, planet):
|
| 118 |
-
result = calculate_weight(earth_weight, planet)
|
| 119 |
-
balloon_script.trigger() # Trigger the balloon effect
|
| 120 |
-
return result
|
| 121 |
-
|
| 122 |
# Submit button and interaction
|
| 123 |
button = gr.Button("Calculate Weight")
|
| 124 |
-
button.click(
|
| 125 |
|
| 126 |
demo.launch()
|
| 127 |
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
# Define gravity constants for each planet as a percentage of Earth's gravity
|
|
|
|
| 40 |
min-height: 100vh;
|
| 41 |
}
|
| 42 |
.gradio-container .output-box {
|
| 43 |
+
animation: fadein 2s ease-in-out;
|
| 44 |
}
|
|
|
|
| 45 |
@keyframes fadein {
|
| 46 |
from { opacity: 0; }
|
| 47 |
to { opacity: 1; }
|
| 48 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
""") as demo:
|
|
|
|
| 50 |
gr.Markdown("# Weight Calculator on Different Planets")
|
| 51 |
gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")
|
| 52 |
|
|
|
|
| 56 |
|
| 57 |
output = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
# Submit button and interaction
|
| 60 |
button = gr.Button("Calculate Weight")
|
| 61 |
+
button.click(calculate_weight, inputs=[earth_weight_input, planet_input], outputs=output)
|
| 62 |
|
| 63 |
demo.launch()
|
| 64 |
|