Spaces:
Sleeping
Sleeping
vighnesh-shetty-vs commited on
Commit ·
8caf4f6
1
Parent(s): d5e582b
Add updated files
Browse files
app.py
CHANGED
|
@@ -46,87 +46,80 @@ def get_stats_html(water, energy, points):
|
|
| 46 |
"""
|
| 47 |
|
| 48 |
def get_drip_visuals(water_level):
|
| 49 |
-
"""Generates
|
| 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
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 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,
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
-
#
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
| 111 |
<defs>
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
<linearGradient id="redGrad" x1="0%" y1="0%" x2="0%" y2="100%">
|
| 117 |
-
<stop offset="0%" style="stop-color:#fca5a5;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 |
-
"""
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
</div>
|
| 131 |
"""
|
| 132 |
|
|
|
|
| 46 |
"""
|
| 47 |
|
| 48 |
def get_drip_visuals(water_level):
|
| 49 |
+
"""Generates the advanced SVG Drip character with dynamic expressions."""
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
if water_level > 70:
|
| 52 |
+
# Happy, Plump
|
| 53 |
+
g_start, g_end = "#7dd3fc", "#0369a1"
|
| 54 |
+
mouth_d = "M43 112 Q60 122 77 112" # Smile
|
| 55 |
+
cracks_op, sweat_op, tear_op = "0", "0", "0"
|
| 56 |
+
mood, mood_color = "Hydrated and (barely) coping", "rgb(34, 211, 238)"
|
| 57 |
anim = "bounce 2s infinite ease-in-out"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
elif 30 <= water_level <= 70:
|
| 59 |
+
# Tired, Sweaty
|
| 60 |
+
g_start, g_end = "#38bdf8", "#0284c7"
|
| 61 |
+
mouth_d = "M43 112 Q60 110 77 112" # Flat / Unamused
|
| 62 |
+
cracks_op, sweat_op, tear_op = "0", "1", "0" # Show sweat
|
| 63 |
+
mood, mood_color = "Shrinking & Sweaty", "#0ea5e9"
|
| 64 |
anim = "float 4s infinite ease-in-out"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
elif water_level > 0:
|
| 66 |
+
# Overheating, Red, Cracked, Crying
|
| 67 |
+
g_start, g_end = "#fca5a5", "#b91c1c"
|
| 68 |
+
mouth_d = "M43 116 Q60 102 77 116" # Frown
|
| 69 |
+
cracks_op, sweat_op, tear_op = "1", "0", "1" # Show cracks and tear
|
| 70 |
+
mood, mood_color = "Overheating & Raspy", "#ef4444"
|
| 71 |
anim = "shake 0.5s infinite"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
else:
|
| 73 |
+
# Evaporated
|
| 74 |
+
g_start, g_end = "#94a3b8", "#334155" # Gray out
|
| 75 |
+
mouth_d = "M40 112 Q45 105 50 112 T60 112 T70 112 T80 112" # Squiggly mouth
|
| 76 |
+
cracks_op, sweat_op, tear_op = "0", "0", "0"
|
| 77 |
+
mood, mood_color = "Evaporated!", "#94a3b8"
|
| 78 |
anim = "floatUp 3s forwards"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
+
return f"""
|
| 81 |
+
<div class="drip-panel" style="animation: {anim}; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%;">
|
| 82 |
+
<div class="drip-lbl" style="font-weight: 800; color: #94a3b8; letter-spacing: 3px; font-size: 14px; margin-bottom: 5px;">DRIP</div>
|
| 83 |
+
|
| 84 |
+
<svg id="drip-svg" viewBox="0 0 120 148" style="width: 140px; height: 160px; overflow: visible;" xmlns="http://www.w3.org/2000/svg">
|
| 85 |
<defs>
|
| 86 |
+
<radialGradient id="dg" cx="38%" cy="32%">
|
| 87 |
+
<stop id="dg1" offset="0%" stop-color="{g_start}"></stop>
|
| 88 |
+
<stop id="dg2" offset="100%" stop-color="{g_end}"></stop>
|
| 89 |
+
</radialGradient>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
</defs>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
<path id="dbody" 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" fill="url(#dg)" stroke="rgba(34,211,238,0.35)" stroke-width="1.5" opacity="1"></path>
|
| 93 |
+
|
| 94 |
+
<ellipse cx="42" cy="70" rx="9" ry="13" fill="rgba(255,255,255,0.22)" transform="rotate(-18,42,70)"></ellipse>
|
| 95 |
+
|
| 96 |
+
<circle cx="44" cy="90" r="10" fill="white"></circle>
|
| 97 |
+
<circle cx="76" cy="90" r="10" fill="white"></circle>
|
| 98 |
+
|
| 99 |
+
<circle id="pl" cx="45" cy="91" r="6" fill="#0f172a"></circle>
|
| 100 |
+
<circle id="pr" cx="77" cy="91" r="6" fill="#0f172a"></circle>
|
| 101 |
+
|
| 102 |
+
<circle cx="47" cy="88" r="2.5" fill="white"></circle>
|
| 103 |
+
<circle cx="79" cy="88" r="2.5" fill="white"></circle>
|
| 104 |
+
|
| 105 |
+
<path id="dm" d="{mouth_d}" stroke="#0f172a" stroke-width="2.5" stroke-linecap="round" fill="none"></path>
|
| 106 |
+
|
| 107 |
+
<g id="cracks" opacity="{cracks_op}" style="transition: opacity 0.5s;">
|
| 108 |
+
<path d="M80 46 L86 58 L79 65 L85 77" stroke="#bae6fd" stroke-width="1.3" stroke-linecap="round" fill="none" opacity=".7"></path>
|
| 109 |
+
<path d="M37 82 L31 93 L39 99" stroke="#bae6fd" stroke-width="1.3" stroke-linecap="round" fill="none" opacity=".7"></path>
|
| 110 |
+
</g>
|
| 111 |
+
|
| 112 |
+
<path id="sweat" d="M108 76 C110 70,116 70,116 78 C116 84,110 88,108 82Z" fill="#7dd3fc" opacity="{sweat_op}" style="transition: opacity 0.5s;"></path>
|
| 113 |
+
|
| 114 |
+
<path id="tear" d="M38 104 C37 108,33 108,33 112 C33 115,36 117,38 114 C40 117,43 115,43 112 C43 108,39 108,38 104Z" fill="#93c5fd" opacity="{tear_op}" style="transition: opacity 0.5s;"></path>
|
| 115 |
+
</svg>
|
| 116 |
+
|
| 117 |
+
<div class="drip-mood" id="drip-mood" style="color: {mood_color}; font-weight: 500; font-size: 1.1rem; margin-top: 15px;">{mood}</div>
|
| 118 |
+
|
| 119 |
+
<div style="text-align:center; margin-top:10px;">
|
| 120 |
+
<div style="font-size:10px; color:#94a3b8; text-transform:uppercase; letter-spacing:1px;">Water Left</div>
|
| 121 |
+
<div style="font-size:26px; font-weight:700; color:{mood_color};" id="d-water">{water_level:.2f}L</div>
|
| 122 |
+
</div>
|
| 123 |
</div>
|
| 124 |
"""
|
| 125 |
|