Spaces:
Sleeping
Sleeping
Deploy Myco from CI
Browse files- ui/interface.py +13 -13
ui/interface.py
CHANGED
|
@@ -1,33 +1,33 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from game.engine import get_myco_narrative
|
| 3 |
|
| 4 |
-
def
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
""
|
| 9 |
|
| 10 |
-
# 1. The Canvas
|
| 11 |
-
|
| 12 |
|
| 13 |
-
# 2. The Narrative Text (
|
| 14 |
narrative = gr.Markdown(value=get_myco_narrative(), elem_id="narrative-box")
|
| 15 |
|
| 16 |
-
# 3. Refresh Timer
|
| 17 |
gr.Timer(10).tick(get_myco_narrative, outputs=narrative)
|
| 18 |
|
| 19 |
-
# 4.
|
| 20 |
gr.HTML("""
|
| 21 |
<script>
|
| 22 |
const canvas = document.getElementById('garden-canvas');
|
| 23 |
const ctx = canvas.getContext('2d');
|
| 24 |
-
|
|
|
|
| 25 |
function drawLoop() {
|
| 26 |
-
//
|
| 27 |
requestAnimationFrame(drawLoop);
|
| 28 |
}
|
| 29 |
drawLoop();
|
| 30 |
</script>
|
| 31 |
""")
|
| 32 |
-
|
| 33 |
return demo
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from game.engine import get_myco_narrative
|
| 3 |
|
| 4 |
+
def render_shroom_tab(): # Kept this name so the import works
|
| 5 |
+
"""
|
| 6 |
+
Renders the garden and narrative without any tabs.
|
| 7 |
+
"""
|
| 8 |
+
with gr.Blocks(css="#garden-canvas { width: 100%; height: 400px; background: #2a4c5e; border-radius: 12px; }") as demo:
|
| 9 |
|
| 10 |
+
# 1. The Canvas (Pure animation, no tab container)
|
| 11 |
+
gr.HTML("<canvas id='garden-canvas'></canvas>")
|
| 12 |
|
| 13 |
+
# 2. The Narrative Text (Engine-powered)
|
| 14 |
narrative = gr.Markdown(value=get_myco_narrative(), elem_id="narrative-box")
|
| 15 |
|
| 16 |
+
# 3. Refresh Timer
|
| 17 |
gr.Timer(10).tick(get_myco_narrative, outputs=narrative)
|
| 18 |
|
| 19 |
+
# 4. Injection of the animation logic
|
| 20 |
gr.HTML("""
|
| 21 |
<script>
|
| 22 |
const canvas = document.getElementById('garden-canvas');
|
| 23 |
const ctx = canvas.getContext('2d');
|
| 24 |
+
|
| 25 |
+
// Your drawing logic here
|
| 26 |
function drawLoop() {
|
| 27 |
+
// ... animation code ...
|
| 28 |
requestAnimationFrame(drawLoop);
|
| 29 |
}
|
| 30 |
drawLoop();
|
| 31 |
</script>
|
| 32 |
""")
|
|
|
|
| 33 |
return demo
|