Spaces:
Sleeping
Sleeping
vighnesh-shetty-vs commited on
Commit ·
d5e582b
1
Parent(s): 36f4c80
Add updated files
Browse files
app.py
CHANGED
|
@@ -48,8 +48,8 @@ def get_stats_html(water, energy, points):
|
|
| 48 |
def get_drip_visuals(water_level):
|
| 49 |
"""Generates an animated SVG character whose expression changes with water level."""
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
|
| 54 |
if water_level > 70:
|
| 55 |
# Happy, Plump, Bouncing
|
|
@@ -57,12 +57,13 @@ def get_drip_visuals(water_level):
|
|
| 57 |
anim = "bounce 2s infinite ease-in-out"
|
| 58 |
glow = "rgba(56,189,248,0.6)"
|
| 59 |
status = "Plump & Hydrated"
|
|
|
|
| 60 |
face = """
|
| 61 |
-
<circle cx="
|
| 62 |
-
<circle cx="
|
| 63 |
-
<path d="M
|
| 64 |
-
<ellipse cx="
|
| 65 |
-
<ellipse cx="
|
| 66 |
"""
|
| 67 |
elif 30 <= water_level <= 70:
|
| 68 |
# Tired, Flat, Sweating
|
|
@@ -70,11 +71,12 @@ def get_drip_visuals(water_level):
|
|
| 70 |
anim = "float 4s infinite ease-in-out"
|
| 71 |
glow = "rgba(56,189,248,0.3)"
|
| 72 |
status = "Shrinking & Tired"
|
|
|
|
| 73 |
face = """
|
| 74 |
-
<path d="M
|
| 75 |
-
<path d="M
|
| 76 |
-
<line x1="
|
| 77 |
-
<path d="M
|
| 78 |
"""
|
| 79 |
elif water_level > 0:
|
| 80 |
# Overheating, Red, Cracked
|
|
@@ -82,28 +84,30 @@ def get_drip_visuals(water_level):
|
|
| 82 |
anim = "shake 0.5s infinite"
|
| 83 |
glow = "rgba(239,68,68,0.5)"
|
| 84 |
status = "Overheating & Raspy"
|
|
|
|
| 85 |
face = """
|
| 86 |
-
<line x1="
|
| 87 |
-
<line x1="
|
| 88 |
-
<line x1="
|
| 89 |
-
<line x1="
|
| 90 |
-
<path d="M
|
| 91 |
"""
|
| 92 |
else:
|
| 93 |
# Ghost / Evaporated
|
| 94 |
-
color = "rgba(148, 163, 184, 0.
|
| 95 |
anim = "floatUp 3s forwards"
|
| 96 |
glow = "transparent"
|
| 97 |
status = "Evaporated!"
|
| 98 |
-
drop_path = "
|
| 99 |
face = """
|
| 100 |
-
<circle cx="
|
| 101 |
-
<circle cx="
|
| 102 |
-
<circle cx="
|
| 103 |
"""
|
| 104 |
|
|
|
|
| 105 |
svg = f"""
|
| 106 |
-
<svg viewBox="0 0
|
| 107 |
<defs>
|
| 108 |
<linearGradient id="blueGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
| 109 |
<stop offset="0%" style="stop-color:#7dd3fc;stop-opacity:1" />
|
|
@@ -114,7 +118,7 @@ def get_drip_visuals(water_level):
|
|
| 114 |
<stop offset="100%" style="stop-color:#b91c1c;stop-opacity:1" />
|
| 115 |
</linearGradient>
|
| 116 |
</defs>
|
| 117 |
-
|
| 118 |
{face}
|
| 119 |
</svg>
|
| 120 |
"""
|
|
@@ -122,7 +126,7 @@ def get_drip_visuals(water_level):
|
|
| 122 |
return f"""
|
| 123 |
<div class="drip-character-container">
|
| 124 |
{svg}
|
| 125 |
-
<h3 style="margin:
|
| 126 |
</div>
|
| 127 |
"""
|
| 128 |
|
|
|
|
| 48 |
def get_drip_visuals(water_level):
|
| 49 |
"""Generates an animated SVG character whose expression changes with water level."""
|
| 50 |
|
| 51 |
+
# The new base path provided by you
|
| 52 |
+
base_drop_path = 'd="M60 8 C60 8,102 66,102 90 C102 118,83 137,60 137 C37 137,18 118,18 90 C18 66,60 8,60 8Z"'
|
| 53 |
|
| 54 |
if water_level > 70:
|
| 55 |
# Happy, Plump, Bouncing
|
|
|
|
| 57 |
anim = "bounce 2s infinite ease-in-out"
|
| 58 |
glow = "rgba(56,189,248,0.6)"
|
| 59 |
status = "Plump & Hydrated"
|
| 60 |
+
drop_path = f'<path id="dbody" {base_drop_path} fill="{color}" stroke="rgba(34,211,238,0.35)" stroke-width="1.5" opacity="1"></path>'
|
| 61 |
face = """
|
| 62 |
+
<circle cx="45" cy="85" r="5" fill="white"/>
|
| 63 |
+
<circle cx="75" cy="85" r="5" fill="white"/>
|
| 64 |
+
<path d="M 50,100 Q 60,115 70,100" stroke="white" stroke-width="3.5" fill="transparent" stroke-linecap="round"/>
|
| 65 |
+
<ellipse cx="35" cy="95" rx="6" ry="4" fill="rgba(255,255,255,0.3)"/>
|
| 66 |
+
<ellipse cx="85" cy="95" rx="6" ry="4" fill="rgba(255,255,255,0.3)"/>
|
| 67 |
"""
|
| 68 |
elif 30 <= water_level <= 70:
|
| 69 |
# Tired, Flat, Sweating
|
|
|
|
| 71 |
anim = "float 4s infinite ease-in-out"
|
| 72 |
glow = "rgba(56,189,248,0.3)"
|
| 73 |
status = "Shrinking & Tired"
|
| 74 |
+
drop_path = f'<path id="dbody" {base_drop_path} fill="{color}" stroke="rgba(34,211,238,0.35)" stroke-width="1.5" opacity="1"></path>'
|
| 75 |
face = """
|
| 76 |
+
<path d="M 40,85 Q 45,80 50,85" stroke="white" stroke-width="3" fill="transparent" stroke-linecap="round"/>
|
| 77 |
+
<path d="M 70,85 Q 75,80 80,85" stroke="white" stroke-width="3" fill="transparent" stroke-linecap="round"/>
|
| 78 |
+
<line x1="55" y1="102" x2="65" y2="102" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
| 79 |
+
<path d="M 85,60 C 85,60 78,75 78,80 A 7,7 0 1,0 92,80 C 92,75 85,60 85,60 Z" fill="rgba(255,255,255,0.6)"/>
|
| 80 |
"""
|
| 81 |
elif water_level > 0:
|
| 82 |
# Overheating, Red, Cracked
|
|
|
|
| 84 |
anim = "shake 0.5s infinite"
|
| 85 |
glow = "rgba(239,68,68,0.5)"
|
| 86 |
status = "Overheating & Raspy"
|
| 87 |
+
drop_path = f'<path id="dbody" {base_drop_path} fill="{color}" stroke="rgba(239,68,68,0.8)" stroke-width="1.5" opacity="1"></path>'
|
| 88 |
face = """
|
| 89 |
+
<line x1="40" y1="80" x2="50" y2="90" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
| 90 |
+
<line x1="50" y1="80" x2="40" y2="90" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
| 91 |
+
<line x1="70" y1="80" x2="80" y2="90" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
| 92 |
+
<line x1="80" y1="80" x2="70" y2="90" stroke="white" stroke-width="3" stroke-linecap="round"/>
|
| 93 |
+
<path d="M 50,105 Q 55,98 60,105 T 70,105" stroke="white" stroke-width="3" fill="transparent" stroke-linecap="round"/>
|
| 94 |
"""
|
| 95 |
else:
|
| 96 |
# Ghost / Evaporated
|
| 97 |
+
color = "rgba(148, 163, 184, 0.4)"
|
| 98 |
anim = "floatUp 3s forwards"
|
| 99 |
glow = "transparent"
|
| 100 |
status = "Evaporated!"
|
| 101 |
+
drop_path = f'<path id="dbody" {base_drop_path} fill="{color}" stroke="rgba(255,255,255,0.2)" stroke-width="1.5" opacity="1"></path>'
|
| 102 |
face = """
|
| 103 |
+
<circle cx="50" cy="80" r="3" fill="white"/>
|
| 104 |
+
<circle cx="70" cy="80" r="3" fill="white"/>
|
| 105 |
+
<circle cx="60" cy="95" r="5" fill="transparent" stroke="white" stroke-width="2"/>
|
| 106 |
"""
|
| 107 |
|
| 108 |
+
# ViewBox expanded to 120x150 to accommodate the new path boundaries
|
| 109 |
svg = f"""
|
| 110 |
+
<svg viewBox="0 0 120 150" style="width: 150px; height: 180px; filter: drop-shadow(0px 0px 15px {glow}); animation: {anim};">
|
| 111 |
<defs>
|
| 112 |
<linearGradient id="blueGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
| 113 |
<stop offset="0%" style="stop-color:#7dd3fc;stop-opacity:1" />
|
|
|
|
| 118 |
<stop offset="100%" style="stop-color:#b91c1c;stop-opacity:1" />
|
| 119 |
</linearGradient>
|
| 120 |
</defs>
|
| 121 |
+
{drop_path}
|
| 122 |
{face}
|
| 123 |
</svg>
|
| 124 |
"""
|
|
|
|
| 126 |
return f"""
|
| 127 |
<div class="drip-character-container">
|
| 128 |
{svg}
|
| 129 |
+
<h3 style="margin: 10px 0 0 0; color: #e2e8f0; font-weight: 600; font-size: 1.1rem; text-align: center;">{status}</h3>
|
| 130 |
</div>
|
| 131 |
"""
|
| 132 |
|