Spaces:
Build error
Build error
Create 11_1st_Conscious_State.py
Browse files- pages/11_1st_Conscious_State.py +122 -0
pages/11_1st_Conscious_State.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
|
| 4 |
+
# Set page configuration
|
| 5 |
+
st.set_page_config(page_title="Interactive Base 50256 Grid", layout="wide")
|
| 6 |
+
|
| 7 |
+
# Title
|
| 8 |
+
st.title("Interactive Base 50256 Grid")
|
| 9 |
+
|
| 10 |
+
# HTML content (your original HTML/JS code)
|
| 11 |
+
html_content = """
|
| 12 |
+
<!DOCTYPE html>
|
| 13 |
+
<html lang="en">
|
| 14 |
+
<head>
|
| 15 |
+
<meta charset="UTF-8">
|
| 16 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 17 |
+
<title>Interactive Base 50256 Grid</title>
|
| 18 |
+
<style>
|
| 19 |
+
body {
|
| 20 |
+
font-family: Arial, sans-serif;
|
| 21 |
+
display: flex;
|
| 22 |
+
justify-content: center;
|
| 23 |
+
align-items: center;
|
| 24 |
+
height: 100vh;
|
| 25 |
+
margin: 0;
|
| 26 |
+
background-color: #f0f0f0;
|
| 27 |
+
}
|
| 28 |
+
.container {
|
| 29 |
+
text-align: center;
|
| 30 |
+
}
|
| 31 |
+
#grid {
|
| 32 |
+
max-width: 80vmin;
|
| 33 |
+
max-height: 80vmin;
|
| 34 |
+
border: 1px solid #ccc;
|
| 35 |
+
}
|
| 36 |
+
.output {
|
| 37 |
+
margin-top: 20px;
|
| 38 |
+
font-size: 18px;
|
| 39 |
+
font-weight: bold;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
</head>
|
| 43 |
+
<body>
|
| 44 |
+
<div class="container">
|
| 45 |
+
<canvas id="grid" width="1000" height="1000"></canvas>
|
| 46 |
+
<div id="clickedOutput" class="output">Click on the grid to select a coordinate</div>
|
| 47 |
+
<div id="hoverOutput">Hover Coordinate: (X: 0, Y: 0)</div>
|
| 48 |
+
</div>
|
| 49 |
+
<script>
|
| 50 |
+
const canvas = document.getElementById('grid');
|
| 51 |
+
const ctx = canvas.getContext('2d');
|
| 52 |
+
const clickedOutput = document.getElementById('clickedOutput');
|
| 53 |
+
const hoverOutput = document.getElementById('hoverOutput');
|
| 54 |
+
|
| 55 |
+
const gridSizeX = 50255;
|
| 56 |
+
const gridSizeY = 50255;
|
| 57 |
+
const cellSizeX = canvas.width / 16;
|
| 58 |
+
const cellSizeY = canvas.height / 16;
|
| 59 |
+
|
| 60 |
+
function drawGrid() {
|
| 61 |
+
ctx.fillStyle = 'white';
|
| 62 |
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
| 63 |
+
|
| 64 |
+
ctx.strokeStyle = '#ccc';
|
| 65 |
+
ctx.lineWidth = 1;
|
| 66 |
+
|
| 67 |
+
for (let i = cellSizeX; i < canvas.width; i += cellSizeX) {
|
| 68 |
+
ctx.beginPath();
|
| 69 |
+
ctx.moveTo(i, 0);
|
| 70 |
+
ctx.lineTo(i, canvas.height);
|
| 71 |
+
ctx.stroke();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
for (let i = cellSizeY; i < canvas.height; i += cellSizeY) {
|
| 75 |
+
ctx.beginPath();
|
| 76 |
+
ctx.moveTo(0, i);
|
| 77 |
+
ctx.lineTo(canvas.width, i);
|
| 78 |
+
ctx.stroke();
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
ctx.fillStyle = 'black';
|
| 82 |
+
ctx.font = '16px Arial';
|
| 83 |
+
ctx.fillText('0,0', 5, canvas.height - 5);
|
| 84 |
+
ctx.fillText(`${gridSizeX},0`, canvas.width - 60, canvas.height - 5);
|
| 85 |
+
ctx.fillText(`0,${gridSizeY}`, 5, 20);
|
| 86 |
+
ctx.fillText(`${gridSizeX},${gridSizeY}`, canvas.width - 100, 20);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
function getCoordinates(event) {
|
| 90 |
+
const rect = canvas.getBoundingClientRect();
|
| 91 |
+
const x = Math.min(Math.floor((event.clientX - rect.left) / rect.width * gridSizeX), gridSizeX);
|
| 92 |
+
const y = Math.min(gridSizeY - Math.floor((event.clientY - rect.top) / rect.height * gridSizeY), gridSizeY);
|
| 93 |
+
return { x, y };
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
canvas.addEventListener('mousemove', (event) => {
|
| 97 |
+
const { x, y } = getCoordinates(event);
|
| 98 |
+
hoverOutput.textContent = `Hover Coordinate: (X: ${x}, Y: ${y})`;
|
| 99 |
+
});
|
| 100 |
+
|
| 101 |
+
canvas.addEventListener('click', (event) => {
|
| 102 |
+
const { x, y } = getCoordinates(event);
|
| 103 |
+
const combinedCoord = x * 100000 + y;
|
| 104 |
+
clickedOutput.textContent = `Clicked Coordinate: ${combinedCoord.toString().padStart(10, '0')}`;
|
| 105 |
+
});
|
| 106 |
+
|
| 107 |
+
canvas.addEventListener('mouseleave', () => {
|
| 108 |
+
hoverOutput.textContent = 'Hover Coordinate: (X: 0, Y: 0)';
|
| 109 |
+
});
|
| 110 |
+
|
| 111 |
+
drawGrid();
|
| 112 |
+
</script>
|
| 113 |
+
</body>
|
| 114 |
+
</html>
|
| 115 |
+
"""
|
| 116 |
+
|
| 117 |
+
# Embed the HTML content
|
| 118 |
+
components.html(html_content, height=700, scrolling=True)
|
| 119 |
+
|
| 120 |
+
# Additional Streamlit content (optional)
|
| 121 |
+
st.write("The interactive grid above is embedded from HTML/JavaScript.")
|
| 122 |
+
st.write("You can click on the grid to select a coordinate, and hover to see the current position.")
|