SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files123434 unmodified lines3940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788893 unmodified lines93949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127import gradio as gr# Define gravity constants for each planet as a percentage of Earth's gravity34 unmodified linesmin-height: 100vh;}.gradio-container .output-box {animation: fadein 2s ease-in-out, scaleup 1s ease-out, textcolor 3s ease-in-out;}@keyframes fadein {from { opacity: 0; }to { opacity: 1; }}@keyframes scaleup {from { transform: scale(0.8); }to { transform: scale(1); }}@keyframes textcolor {0% { color: #ff7e5f; }50% { color: #feb47b; }100% { color: #00b4d8; }}/* Balloon Animation */.balloon {position: absolute;bottom: 0;animation: rise 6s ease-in-out forwards, float 4s ease-in-out infinite;}@keyframes rise {0% { bottom: 0; opacity: 1; }100% { bottom: 90%; opacity: 0; }}@keyframes float {0% { transform: translateX(0); }50% { transform: translateX(30px); }100% { transform: translateX(0); }}.balloon-text {font-size: 1.5rem;color: white;text-align: center;font-weight: bold;}""") as demo:gr.Markdown("# Weight Calculator on Different Planets")gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")3 unmodified linesoutput = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)# HTML component for balloon effect triggerballoon_script = gr.HTML("""<script>function triggerBalloonEffect() {const balloonCount = 5; // Number of balloons to showfor (let i = 0; i < balloonCount; i++) {let balloon = document.createElement('div');balloon.classList.add('balloon');balloon.style.left = Math.random() * 100 + 'vw'; // Random horizontal positionlet balloonText = document.createElement('div');balloonText.classList.add('balloon-text');balloonText.textContent = '🎈'; // Emoji or custom text for the balloonballoon.appendChild(balloonText);document.body.appendChild(balloon);setTimeout(() => balloon.remove(), 6000); // Remove balloon after animation}}</script>""")# Function to trigger balloon effectdef trigger_balloon_and_weight(earth_weight, planet):result = calculate_weight(earth_weight, planet)balloon_script.trigger() # Trigger the balloon effectreturn result# Submit button and interactionbutton = gr.Button("Calculate Weight")button.click(trigger_balloon_and_weight, inputs=[earth_weight_input, planet_input], outputs=output)demo.launch()1234534 unmodified lines404142434445464748495051523 unmodified lines565758596061626364import gradio as gr# Define gravity constants for each planet as a percentage of Earth's gravity34 unmodified linesmin-height: 100vh;}.gradio-container .output-box {animation: fadein 2s ease-in-out;}@keyframes fadein {from { opacity: 0; }to { opacity: 1; }}""") as demo:gr.Markdown("# Weight Calculator on Different Planets")gr.Markdown("Enter your weight on Earth and choose a planet to find your weight on it.")3 unmodified linesoutput = gr.Textbox(label="Equivalent Weight on Planet", interactive=False)# Submit button and interactionbutton = gr.Button("Calculate Weight")button.click(calculate_weight, inputs=[earth_weight_input, planet_input], outputs=output)demo.launch()
app.py+4-67