Spaces:
Sleeping

byte-vortex commited on
Commit
23167e0
ยท
verified ยท
1 Parent(s): 9044b78

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/interface.py +30 -57
ui/interface.py CHANGED
@@ -2,8 +2,8 @@ import gradio as gr
2
 
3
  def myco_animation_card_markdown() -> str:
4
  """
5
- Generates a self-contained, micro-scoped HTML/Canvas card component.
6
- Equipped with a fluid layout-tracker to handle Gradio tab transition scaling.
7
  """
8
  return """
9
  <div id="myco-card-container" class="myco-anim-card">
@@ -15,7 +15,7 @@ def myco_animation_card_markdown() -> str:
15
  height: 320px;
16
  margin: 20px auto;
17
  background: #050a08;
18
- border: 1px solid rgba(82, 255, 107, 0.2);
19
  border-radius: 12px;
20
  overflow: hidden;
21
  font-family: 'Inter', sans-serif;
@@ -28,7 +28,6 @@ def myco_animation_card_markdown() -> str:
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; }
@@ -62,7 +61,7 @@ def myco_animation_card_markdown() -> str:
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); }
@@ -76,37 +75,41 @@ def myco_animation_card_markdown() -> str:
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() {
@@ -125,43 +128,22 @@ def myco_animation_card_markdown() -> str:
125
  }
126
  }
127
 
128
- for (let i = 0; i < 600; i++) {
 
129
  particles.push(new Spore());
130
  }
131
 
132
- function syncCanvasDimensions() {
133
- if (!container || !container.clientWidth) return false;
134
-
135
- w = container.clientWidth;
136
- h = container.clientHeight;
137
-
138
- if (w === lastW && h === lastH) return true;
139
-
140
- const dpr = window.devicePixelRatio || 1;
141
- canvas.width = w * dpr;
142
- canvas.height = h * dpr;
143
- ctx.scale(dpr, dpr);
144
-
145
- sCanvas.width = w;
146
- sCanvas.height = h;
147
-
148
- lastW = w;
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();
@@ -187,14 +169,12 @@ def myco_animation_card_markdown() -> str:
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() {
@@ -205,7 +185,7 @@ def myco_animation_card_markdown() -> str:
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";
@@ -216,13 +196,11 @@ def myco_animation_card_markdown() -> str:
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(() => {
@@ -241,13 +219,7 @@ def myco_animation_card_markdown() -> str:
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(); });
@@ -268,7 +240,10 @@ def myco_animation_card_markdown() -> str:
268
  }
269
 
270
  ctx = canvas.getContext('2d');
271
- dateEl.textContent = "LIVE STUDIO // " + new Date().toLocaleTimeString();
 
 
 
272
  renderFrameLoop();
273
  }
274
 
@@ -284,11 +259,9 @@ def render_shroom_tab():
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 ๐Ÿšจ")
 
2
 
3
  def myco_animation_card_markdown() -> str:
4
  """
5
+ Generates a self-contained HTML/Canvas component.
6
+ Uses a fixed internal virtual matrix resolution to bypass Gradio tab-hiding bugs.
7
  """
8
  return """
9
  <div id="myco-card-container" class="myco-anim-card">
 
15
  height: 320px;
16
  margin: 20px auto;
17
  background: #050a08;
18
+ border: 1px solid rgba(82, 255, 107, 0.25);
19
  border-radius: 12px;
20
  overflow: hidden;
21
  font-family: 'Inter', sans-serif;
 
28
  pointer-events: none;
29
  z-index: 1;
30
  opacity: 0.15;
 
31
  }
32
 
33
  .m-grid { background-image: radial-gradient(rgba(82, 255, 107, 0.25) 1px, transparent 1px); background-size: 20px 20px; }
 
61
  .myco-highlight { color: #00f2fe; font-weight: bold; }
62
 
63
  @keyframes cardShake {
64
+ 0% { transform: translate(1px, 1px); }
65
  20% { transform: translate(-1px, -1px); }
66
  40% { transform: translate(1px, -1px); }
67
  100% { transform: translate(1px, 1px); }
 
75
  <small style="font-size: 7px; color: #ff4500; opacity: 0.9; letter-spacing: 0.5px;">๐Ÿ”ด GEMMA AI IS BROADCASTING LIVE</small>
76
  </div>
77
 
78
+ <canvas id="myco-card-canvas" width="600" height="320"></canvas>
79
 
80
  <div id="myco-card-footer">
81
+ <div>STREAM ENGINE: <span class="myco-highlight">SPORE NET v4.0</span></div>
82
  <div id="myco-card-date"></div>
83
  </div>
84
 
85
  <script>
86
  (function() {
87
  let container, canvas, ctx, overlay, msg, dateEl;
88
+
89
+ // FIXED VIRTUAL MATRIX DIMENSIONS
90
+ const w = 600;
91
+ const h = 320;
92
 
93
  const textures = ['m-grid', 'm-lines', 'm-noise'];
94
  const sequence = ["๐Ÿ„", "GEMMA", "SCREAMING", "SPORES", "UNHINGED", "๐Ÿ„โ€๐ŸŸซ", "MATRIX", "HYPHAE", "LIVE"];
95
 
96
  let currentStep = 0;
97
  let isExposed = false;
 
98
  let particles = [];
99
  let mutationTimer = null;
100
 
101
  const sCanvas = document.createElement('canvas');
102
+ sCanvas.width = w;
103
+ sCanvas.height = h;
104
  const sCtx = sCanvas.getContext('2d', { willReadFrequently: true });
105
 
106
  class Spore {
107
  constructor() {
108
+ this.x = Math.random() * w;
109
+ this.y = Math.random() * h;
110
  this.tx = this.x; this.ty = this.y;
111
  this.vx = 0; this.vy = 0;
112
+ this.size = Math.random() * 2 + 1;
113
  this.color = '#52ff6b';
114
  }
115
  update() {
 
128
  }
129
  }
130
 
131
+ // Generate immediate baseline spore field
132
+ for (let i = 0; i < 700; i++) {
133
  particles.push(new Spore());
134
  }
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  function morph(content) {
137
+ if (!ctx) return;
 
138
  sCtx.clearRect(0, 0, w, h);
139
  sCtx.fillStyle = "white";
140
  sCtx.textAlign = "center";
141
  sCtx.textBaseline = "middle";
142
 
143
+ const baseSize = h * 0.55;
144
  const fontSize = content.length > 2 ? baseSize / (content.length * 0.45) : baseSize;
145
  sCtx.font = `bold ${fontSize}px sans-serif`;
146
+ sCtx.fillText(content, w / 2, h / 2 + 10);
147
 
148
  overlay.className = textures[currentStep % textures.length];
149
  overlay.style.opacity = (0.05 + (Math.random() * 0.08)).toString();
 
169
  if (content === "BOOM") {
170
  p.color = "#00f2fe";
171
  } else {
172
+ p.color = `hsl(${110 + (currentStep * 24)}, 90%, 65%)`;
173
  }
174
  });
175
 
176
+ container.classList.add('card-shaking');
177
+ setTimeout(() => container.classList.remove('card-shaking'), 90);
 
 
178
  }
179
 
180
  function burst() {
 
185
 
186
  particles.forEach(p => {
187
  const angle = Math.random() * Math.PI * 2;
188
+ const vel = Math.random() * 16 + 6;
189
  p.vx = Math.cos(angle) * vel;
190
  p.vy = Math.sin(angle) * vel;
191
  p.color = "#ff4500";
 
196
  msg.innerText = "FEED STABILIZED";
197
  currentStep = 0;
198
  morph("BOOM");
199
+ }, 1600);
200
  }
201
 
202
  function startStreamTicker() {
203
  if (mutationTimer) return;
 
 
204
  morph(sequence[currentStep]);
205
 
206
  mutationTimer = setInterval(() => {
 
219
  }
220
 
221
  function renderFrameLoop() {
222
+ if (ctx) {
 
 
 
 
 
 
223
  ctx.fillStyle = 'rgba(5, 10, 8, 0.25)';
224
  ctx.fillRect(0, 0, w, h);
225
  particles.forEach(p => { p.update(); p.draw(); });
 
240
  }
241
 
242
  ctx = canvas.getContext('2d');
243
+ dateEl.textContent = "LIVE STUDIO // ONLINE";
244
+
245
+ // Fire layout systems immediately without waiting for browser tabs
246
+ startStreamTicker();
247
  renderFrameLoop();
248
  }
249
 
 
259
  Reskinned into the ultimate Gemma AI Shroom Podcast Studio.
260
  """
261
  with gr.Tabs():
 
262
  with gr.Tab("๐Ÿ”ฎ Mutation Matrix"):
263
  gr.HTML(value=myco_animation_card_markdown())
264
 
 
265
  with gr.Tab("๐ŸŽ™๏ธ GEMMA LIVE STREAM"):
266
  with gr.Group():
267
  gr.Markdown("# ๐Ÿšจ WE ARE LIVE: THE SPORE NATION PODCAST ๐Ÿšจ")