Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/interface.py +76 -276
ui/interface.py
CHANGED
|
@@ -1,294 +1,94 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
def myco_animation_card_markdown() -> str:
|
| 4 |
"""
|
| 5 |
-
|
| 6 |
-
|
| 7 |
"""
|
| 8 |
-
|
| 9 |
-
<
|
| 10 |
-
<
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
top: 0; left: 0; width: 100%; height: 100%;
|
| 28 |
-
pointer-events: none;
|
| 29 |
-
z-index: 1;
|
| 30 |
-
opacity: 0.15;
|
| 31 |
-
transition: opacity 0.4s ease;
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
.m-grid { background-image: radial-gradient(rgba(82, 255, 107, 0.25) 1px, transparent 1px); background-size: 20px 20px; }
|
| 35 |
-
.m-lines { background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(82, 255, 107, 0.05) 3px); }
|
| 36 |
-
.m-noise { background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
|
| 37 |
-
|
| 38 |
-
#myco-card-canvas {
|
| 39 |
-
display: block;
|
| 40 |
-
position: absolute;
|
| 41 |
-
top: 0; left: 0;
|
| 42 |
-
width: 100%;
|
| 43 |
-
height: 100%;
|
| 44 |
-
z-index: 2;
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
#myco-card-ui {
|
| 48 |
-
position: absolute; top: 14px; left: 0; width: 100%;
|
| 49 |
-
color: #52ff6b; font-size: 10px; letter-spacing: 3px;
|
| 50 |
-
pointer-events: none; text-transform: uppercase; z-index: 10;
|
| 51 |
-
text-align: center; line-height: 1.6;
|
| 52 |
-
text-shadow: 0 0 4px rgba(82, 255, 107, 0.4);
|
| 53 |
-
}
|
| 54 |
-
|
| 55 |
-
#myco-card-footer {
|
| 56 |
-
position: absolute; bottom: 12px; left: 16px; right: 16px;
|
| 57 |
-
color: rgba(82, 255, 107, 0.4); font-size: 8px;
|
| 58 |
-
letter-spacing: 1px; text-transform: uppercase; z-index: 10;
|
| 59 |
-
display: flex; justify-content: space-between;
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
.myco-highlight { color: #00f2fe; font-weight: bold; }
|
| 63 |
-
|
| 64 |
-
@keyframes cardShake {
|
| 65 |
-
0 { transform: translate(1px, 1px); }
|
| 66 |
-
20% { transform: translate(-1px, -1px); }
|
| 67 |
-
40% { transform: translate(1px, -1px); }
|
| 68 |
-
100% { transform: translate(1px, 1px); }
|
| 69 |
-
}
|
| 70 |
-
.card-shaking { animation: cardShake 0.12s infinite; }
|
| 71 |
-
</style>
|
| 72 |
-
|
| 73 |
-
<div id="myco-card-overlay" class="m-grid"></div>
|
| 74 |
-
<div id="myco-card-ui">
|
| 75 |
-
PODCAST STREAM MUTATION: <span id="myco-card-msg">CONNECTING FEED...</span><br>
|
| 76 |
-
<small style="font-size: 7px; color: #ff4500; opacity: 0.9; letter-spacing: 0.5px;">🔴 GEMMA AI IS BROADCASTING LIVE</small>
|
| 77 |
-
</div>
|
| 78 |
-
|
| 79 |
-
<canvas id="myco-card-canvas"></canvas>
|
| 80 |
-
|
| 81 |
-
<div id="myco-card-footer">
|
| 82 |
-
<div>STREAM ENGINE: <span class="myco-highlight">SPORE NET v3.9</span></div>
|
| 83 |
-
<div id="myco-card-date"></div>
|
| 84 |
-
</div>
|
| 85 |
-
|
| 86 |
-
<script>
|
| 87 |
-
(function() {
|
| 88 |
-
let container, canvas, ctx, overlay, msg, dateEl;
|
| 89 |
-
let audioCtx = null;
|
| 90 |
-
|
| 91 |
-
const textures = ['m-grid', 'm-lines', 'm-noise'];
|
| 92 |
-
const sequence = ["🍄", "GEMMA", "SCREAMING", "SPORES", "UNHINGED", "🍄🟫", "MATRIX", "HYPHAE", "LIVE"];
|
| 93 |
-
|
| 94 |
-
let currentStep = 0;
|
| 95 |
-
let isExposed = false;
|
| 96 |
-
let w = 0, h = 0, lastW = 0, lastH = 0;
|
| 97 |
-
let particles = [];
|
| 98 |
-
let mutationTimer = null;
|
| 99 |
-
|
| 100 |
-
const sCanvas = document.createElement('canvas');
|
| 101 |
-
const sCtx = sCanvas.getContext('2d', { willReadFrequently: true });
|
| 102 |
-
|
| 103 |
-
class Spore {
|
| 104 |
-
constructor() {
|
| 105 |
-
this.x = Math.random() * 400;
|
| 106 |
-
this.y = Math.random() * 320;
|
| 107 |
-
this.tx = this.x; this.ty = this.y;
|
| 108 |
-
this.vx = 0; this.vy = 0;
|
| 109 |
-
this.size = Math.random() * 1.8 + 1;
|
| 110 |
-
this.color = '#52ff6b';
|
| 111 |
-
}
|
| 112 |
-
update() {
|
| 113 |
-
if (isExposed) {
|
| 114 |
-
this.x += this.vx; this.y += this.vy;
|
| 115 |
-
this.vx *= 0.96; this.vy *= 0.96;
|
| 116 |
-
} else {
|
| 117 |
-
this.vx = (this.tx - this.x) * 0.18;
|
| 118 |
-
this.vy = (this.ty - this.y) * 0.18;
|
| 119 |
-
this.x += this.vx; this.y += this.vy;
|
| 120 |
-
}
|
| 121 |
}
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
}
|
| 126 |
-
}
|
| 127 |
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
lastH = h;
|
| 150 |
-
return true;
|
| 151 |
-
}
|
| 152 |
-
|
| 153 |
-
function morph(content) {
|
| 154 |
-
if (!syncCanvasDimensions()) return;
|
| 155 |
-
|
| 156 |
-
sCtx.clearRect(0, 0, w, h);
|
| 157 |
-
sCtx.fillStyle = "white";
|
| 158 |
-
sCtx.textAlign = "center";
|
| 159 |
-
sCtx.textBaseline = "middle";
|
| 160 |
-
|
| 161 |
-
const baseSize = Math.min(w, h) * 0.5;
|
| 162 |
-
const fontSize = content.length > 2 ? baseSize / (content.length * 0.45) : baseSize;
|
| 163 |
-
sCtx.font = `bold ${fontSize}px sans-serif`;
|
| 164 |
-
sCtx.fillText(content, w / 2, h / 2 + 15);
|
| 165 |
-
|
| 166 |
-
overlay.className = textures[currentStep % textures.length];
|
| 167 |
-
overlay.style.opacity = (0.05 + (Math.random() * 0.08)).toString();
|
| 168 |
-
|
| 169 |
-
const imgData = sCtx.getImageData(0, 0, w, h).data;
|
| 170 |
-
const points = [];
|
| 171 |
-
|
| 172 |
-
for (let y = 0; y < h; y += 4) {
|
| 173 |
-
for (let x = 0; x < w; x += 4) {
|
| 174 |
-
if (imgData[(y * w + x) * 4 + 3] > 128) points.push({x, y});
|
| 175 |
-
}
|
| 176 |
-
}
|
| 177 |
-
|
| 178 |
-
if (points.length === 0) return;
|
| 179 |
-
|
| 180 |
-
if (particles.length < points.length) {
|
| 181 |
-
while(particles.length < points.length) particles.push(new Spore());
|
| 182 |
-
}
|
| 183 |
-
|
| 184 |
-
particles.forEach((p, i) => {
|
| 185 |
-
const pt = points[i % points.length];
|
| 186 |
-
p.tx = pt.x; p.ty = pt.y;
|
| 187 |
-
if (content === "BOOM") {
|
| 188 |
-
p.color = "#00f2fe";
|
| 189 |
-
} else {
|
| 190 |
-
p.color = `hsl(${110 + (currentStep * 25)}, 90%, 65%)`;
|
| 191 |
-
}
|
| 192 |
-
});
|
| 193 |
-
|
| 194 |
-
if (content !== "BOOM") {
|
| 195 |
-
container.classList.add('card-shaking');
|
| 196 |
-
setTimeout(() => container.classList.remove('card-shaking'), 90);
|
| 197 |
-
}
|
| 198 |
-
}
|
| 199 |
-
|
| 200 |
-
function burst() {
|
| 201 |
-
isExposed = true;
|
| 202 |
-
msg.innerText = "🚨 MAX VOLUME DISTORTION 🚨";
|
| 203 |
-
overlay.className = 'm-noise';
|
| 204 |
-
overlay.style.opacity = "0.4";
|
| 205 |
-
|
| 206 |
-
particles.forEach(p => {
|
| 207 |
-
const angle = Math.random() * Math.PI * 2;
|
| 208 |
-
const vel = Math.random() * 18 + 6;
|
| 209 |
-
p.vx = Math.cos(angle) * vel;
|
| 210 |
-
p.vy = Math.sin(angle) * vel;
|
| 211 |
-
p.color = "#ff4500";
|
| 212 |
-
});
|
| 213 |
-
|
| 214 |
-
setTimeout(() => {
|
| 215 |
-
isExposed = false;
|
| 216 |
-
msg.innerText = "FEED STABILIZED";
|
| 217 |
-
currentStep = 0;
|
| 218 |
-
morph("BOOM");
|
| 219 |
-
}, 1500);
|
| 220 |
-
}
|
| 221 |
-
|
| 222 |
-
function startStreamTicker() {
|
| 223 |
-
if (mutationTimer) return;
|
| 224 |
-
|
| 225 |
-
msg.innerText = `MUTATION // ${sequence[currentStep]}`;
|
| 226 |
-
morph(sequence[currentStep]);
|
| 227 |
-
|
| 228 |
-
mutationTimer = setInterval(() => {
|
| 229 |
-
if (!isExposed && msg.innerText !== "FEED STABILIZED") {
|
| 230 |
-
currentStep++;
|
| 231 |
-
if (currentStep < sequence.length) {
|
| 232 |
-
msg.innerText = `LIVE BROADCAST // ${sequence[currentStep]}`;
|
| 233 |
-
morph(sequence[currentStep]);
|
| 234 |
-
} else {
|
| 235 |
-
clearInterval(mutationTimer);
|
| 236 |
-
mutationTimer = null;
|
| 237 |
-
burst();
|
| 238 |
-
}
|
| 239 |
-
}
|
| 240 |
-
}, 1200);
|
| 241 |
-
}
|
| 242 |
-
|
| 243 |
-
function renderFrameLoop() {
|
| 244 |
-
const isVisible = syncCanvasDimensions();
|
| 245 |
-
|
| 246 |
-
if (isVisible && w > 100 && !mutationTimer && !isExposed && currentStep === 0) {
|
| 247 |
-
startStreamTicker();
|
| 248 |
-
}
|
| 249 |
-
|
| 250 |
-
if (w > 0 && h > 0 && ctx) {
|
| 251 |
-
ctx.fillStyle = 'rgba(5, 10, 8, 0.25)';
|
| 252 |
-
ctx.fillRect(0, 0, w, h);
|
| 253 |
-
particles.forEach(p => { p.update(); p.draw(); });
|
| 254 |
-
}
|
| 255 |
-
requestAnimationFrame(renderFrameLoop);
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
function bootstrapEngine() {
|
| 259 |
-
container = document.getElementById('myco-card-container');
|
| 260 |
-
canvas = document.getElementById('myco-card-canvas');
|
| 261 |
-
overlay = document.getElementById('myco-card-overlay');
|
| 262 |
-
msg = document.getElementById('myco-card-msg');
|
| 263 |
-
dateEl = document.getElementById('myco-card-date');
|
| 264 |
-
|
| 265 |
-
if (!container || !canvas || !overlay || !msg || !dateEl) {
|
| 266 |
-
setTimeout(bootstrapEngine, 50);
|
| 267 |
-
return;
|
| 268 |
}
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
def render_shroom_tab():
|
| 282 |
-
"""
|
| 283 |
-
Houses layout rendering parameters within a dedicated component ecosystem.
|
| 284 |
-
Reskinned into the ultimate Gemma AI Shroom Podcast Studio.
|
| 285 |
-
"""
|
| 286 |
with gr.Tabs():
|
| 287 |
-
# Sub-Tab 1: The dynamic neon spore animation engine
|
| 288 |
with gr.Tab("🔮 Mutation Matrix"):
|
| 289 |
gr.HTML(value=myco_animation_card_markdown())
|
| 290 |
|
| 291 |
-
# Sub-Tab 2: The Screaming YouTube Influencer Content Panel
|
| 292 |
with gr.Tab("🎙️ GEMMA LIVE STREAM"):
|
| 293 |
with gr.Group():
|
| 294 |
gr.Markdown("# 🚨 WE ARE LIVE: THE SPORE NATION PODCAST 🚨")
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import html
|
| 3 |
|
| 4 |
def myco_animation_card_markdown() -> str:
|
| 5 |
"""
|
| 6 |
+
Pure iframe srcdoc implementation.
|
| 7 |
+
Zero UI cards, zero React interference. Just the spore matrix.
|
| 8 |
"""
|
| 9 |
+
iframe_content = """
|
| 10 |
+
<!DOCTYPE html>
|
| 11 |
+
<html>
|
| 12 |
+
<head>
|
| 13 |
+
<style>
|
| 14 |
+
body { margin: 0; overflow: hidden; background: #050a08; }
|
| 15 |
+
canvas { display: block; }
|
| 16 |
+
</style>
|
| 17 |
+
</head>
|
| 18 |
+
<body>
|
| 19 |
+
<canvas id="spore-canvas"></canvas>
|
| 20 |
+
<script>
|
| 21 |
+
const canvas = document.getElementById('spore-canvas');
|
| 22 |
+
const ctx = canvas.getContext('2d');
|
| 23 |
+
|
| 24 |
+
// Handles iframe resizing automatically
|
| 25 |
+
function resize() {
|
| 26 |
+
canvas.width = window.innerWidth;
|
| 27 |
+
canvas.height = window.innerHeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
+
window.addEventListener('resize', resize);
|
| 30 |
+
resize();
|
| 31 |
+
|
| 32 |
+
// Setup Spores
|
| 33 |
+
const particles = [];
|
| 34 |
+
for(let i = 0; i < 800; i++) {
|
| 35 |
+
particles.push({
|
| 36 |
+
x: Math.random() * canvas.width,
|
| 37 |
+
y: Math.random() * canvas.height,
|
| 38 |
+
vx: (Math.random() - 0.5) * 1.5,
|
| 39 |
+
vy: (Math.random() - 0.5) * 1.5,
|
| 40 |
+
size: Math.random() * 2 + 0.5,
|
| 41 |
+
color: Math.random() > 0.85 ? '#00f2fe' : '#52ff6b' // 15% Blue, 85% Green
|
| 42 |
+
});
|
| 43 |
}
|
|
|
|
| 44 |
|
| 45 |
+
// Animation Loop
|
| 46 |
+
function draw() {
|
| 47 |
+
// Creates the trailing effect
|
| 48 |
+
ctx.fillStyle = 'rgba(5, 10, 8, 0.2)';
|
| 49 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 50 |
+
|
| 51 |
+
particles.forEach(p => {
|
| 52 |
+
p.x += p.vx;
|
| 53 |
+
p.y += p.vy;
|
| 54 |
+
|
| 55 |
+
// Seamless screen wrapping
|
| 56 |
+
if(p.x < 0) p.x = canvas.width;
|
| 57 |
+
if(p.x > canvas.width) p.x = 0;
|
| 58 |
+
if(p.y < 0) p.y = canvas.height;
|
| 59 |
+
if(p.y > canvas.height) p.y = 0;
|
| 60 |
+
|
| 61 |
+
ctx.fillStyle = p.color;
|
| 62 |
+
ctx.fillRect(p.x, p.y, p.size, p.size);
|
| 63 |
+
});
|
| 64 |
+
|
| 65 |
+
requestAnimationFrame(draw);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
}
|
| 67 |
+
draw();
|
| 68 |
+
</script>
|
| 69 |
+
</body>
|
| 70 |
+
</html>
|
| 71 |
+
"""
|
| 72 |
+
|
| 73 |
+
# Safely escape the HTML so Gradio parses it flawlessly
|
| 74 |
+
escaped_srcdoc = html.escape(iframe_content)
|
| 75 |
+
|
| 76 |
+
# Return it wrapped in an isolated iframe bounding box
|
| 77 |
+
return f'''
|
| 78 |
+
<div style="width: 100%; height: 400px; border-radius: 8px; overflow: hidden; border: 1px solid rgba(82, 255, 107, 0.3);">
|
| 79 |
+
<iframe
|
| 80 |
+
srcdoc="{escaped_srcdoc}"
|
| 81 |
+
style="width: 100%; height: 100%; border: none;"
|
| 82 |
+
scrolling="no">
|
| 83 |
+
</iframe>
|
| 84 |
+
</div>
|
| 85 |
+
'''
|
| 86 |
|
| 87 |
def render_shroom_tab():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
with gr.Tabs():
|
|
|
|
| 89 |
with gr.Tab("🔮 Mutation Matrix"):
|
| 90 |
gr.HTML(value=myco_animation_card_markdown())
|
| 91 |
|
|
|
|
| 92 |
with gr.Tab("🎙️ GEMMA LIVE STREAM"):
|
| 93 |
with gr.Group():
|
| 94 |
gr.Markdown("# 🚨 WE ARE LIVE: THE SPORE NATION PODCAST 🚨")
|