Spaces:
Sleeping

byte-vortex commited on
Commit
80a67e5
·
verified ·
1 Parent(s): f11d013

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. ui/interface.py +29 -33
ui/interface.py CHANGED
@@ -1,37 +1,33 @@
1
  import gradio as gr
2
  from game.engine import get_myco_narrative
3
 
4
- def get_new_narrative_json():
5
- # This prepares the text to be passed to the JS layer
6
- return get_myco_narrative()
7
-
8
- def render_shroom_tab():
9
- with gr.Tabs():
10
- with gr.Tab("✨ Gemma's Magic Mushroom Garden"):
11
- # A hidden textbox to hold the latest AI thought
12
- narrative_box = gr.Textbox(
13
- value=get_myco_narrative(),
14
- visible=False,
15
- elem_id="myco-text-bridge"
16
- )
17
-
18
- # The garden container
19
- gr.HTML(value="""
20
- <div id="garden-container" style="position:relative; width:100%; height:500px;">
21
- <div id="gemma-bubble" style="position:absolute; top:20px; z-index:100; ..."></div>
22
- <canvas id="cute-canvas"></canvas>
23
- </div>
24
- <script>
25
- // This JS reads the text from the hidden Gradio textbox
26
- function updateBubble() {
27
- const bridge = document.getElementById('myco-text-bridge');
28
- const bubble = document.getElementById('gemma-bubble');
29
- if(bridge) bubble.innerText = "Gemma Myco AI: " + bridge.value;
30
- }
31
- // Run updateBubble whenever the hidden bridge changes
32
- </script>
33
- """)
34
-
35
- # Use an event to refresh the narrative every 10 seconds
36
- gr.Timer(10).tick(get_myco_narrative, outputs=narrative_box)
37
 
 
 
1
  import gradio as gr
2
  from game.engine import get_myco_narrative
3
 
4
+ def render_garden_page():
5
+ with gr.Blocks(css="""
6
+ #garden-canvas { width: 100%; height: 400px; background: #2a4c5e; border-radius: 12px; }
7
+ #narrative-box { font-family: 'Courier New', monospace; font-size: 16px; color: #4a3b32; text-align: center; padding: 20px; }
8
+ """) as demo:
9
+
10
+ # 1. The Canvas
11
+ garden_canvas = gr.HTML("<canvas id='garden-canvas'></canvas>")
12
+
13
+ # 2. The Narrative Text (Updated by the AI engine)
14
+ narrative = gr.Markdown(value=get_myco_narrative(), elem_id="narrative-box")
15
+
16
+ # 3. Refresh Timer (Updates every 10 seconds)
17
+ gr.Timer(10).tick(get_myco_narrative, outputs=narrative)
18
+
19
+ # 4. The Animation Logic (Pure JS injected once)
20
+ gr.HTML("""
21
+ <script>
22
+ const canvas = document.getElementById('garden-canvas');
23
+ const ctx = canvas.getContext('2d');
24
+ // ... [Insert your cute mushroom drawing loop here] ...
25
+ function drawLoop() {
26
+ // Your drawing logic
27
+ requestAnimationFrame(drawLoop);
28
+ }
29
+ drawLoop();
30
+ </script>
31
+ """)
 
 
 
 
 
32
 
33
+ return demo