File size: 3,590 Bytes
57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 4084515 a7d2ddc 57b3cfe 4084515 a7d2ddc 57b3cfe a7d2ddc 4084515 a7d2ddc 57b3cfe a7d2ddc 57b3cfe a7d2ddc 57b3cfe 4084515 57b3cfe a7d2ddc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
import streamlit as st
def create_brain_animation_app():
st.title("AI Memory & Brain Visualization")
st.write("This visualization represents AI learning and memory enhancement, shaped like a brain's neocortex.")
# JavaScript code for the brain-shaped animation with SVG text
js_code = """
<svg id="brainCanvas" width="100%" height="100%" style="position:fixed; top:0; left:0;"></svg>
<script>
const svg = document.getElementById('brainCanvas');
const ns = 'http://www.w3.org/2000/svg';
let t = 0;
function mag(x, y) {
return Math.sqrt(x * x + y * y);
}
function brainShape(x, y) {
let k = x/8 - 25, e = y/8 - 25;
let d = mag(k, e)**2 / 99;
let q = x/3 + k * 0.5 / Math.cos(y*5) * Math.sin(d*d - t);
let c = d/2 - t/8;
let xPos = q * Math.sin(c) + e * Math.sin(d + k - t) + svg.clientWidth / 2;
let yPos = (q + y/8 + d*9) * Math.cos(c) + svg.clientHeight / 2;
return[xPos, yPos];
}
function getColor(x, y, t) {
const hue = (Math.sin(t/2) * 360 + x/3 + y/3) % 360;
return `hsl(${hue}, 70%, 50%)`;
}
function drawBrain() {
// Clear previous circles
while (svg.firstChild) {
svg.removeChild(svg.firstChild);
}
const circleRadius = 1;
for (let y = 99; y < svg.clientHeight - 99; y += 4) {
for (let x = 99; x < svg.clientWidth - 99; x += 2) {
const[px, py] = brainShape(x, y);
if (Math.sqrt(px*px + py*py) > svg.clientWidth * 0.3 && Math.sqrt(px*px + py*py) < svg.clientWidth * 0.6) {
const circle = document.createElementNS(ns, 'circle');
circle.setAttribute('cx', px);
circle.setAttribute('cy', py);
circle.setAttribute('r', circleRadius);
circle.setAttribute('fill', getColor(x, y, t));
svg.appendChild(circle);
}
}
}
t += Math.PI / 180;
requestAnimationFrame(drawBrain);
}
function addScrollingText(text) {
const textElement = document.createElementNS(ns, 'text');
textElement.setAttribute('x', '50%');
textElement.setAttribute('y', '10%');
textElement.setAttribute('dy', '0.3em');
textElement.setAttribute('text-anchor', 'middle');
textElement.setAttribute('fill', 'white');
textElement.setAttribute('font-size', '20px');
textElement.textContent = text;
svg.appendChild(textElement);
let startX = 0;
function animateText() {
startX = (startX - 1) % (svg.clientWidth + 200);
textElement.setAttribute('transform', `translate(${startX}, 0)`);
requestAnimationFrame(animateText);
}
animateText();
}
drawBrain();
addScrollingText("AI Memory & Brain Visualization");
</script>
"""
# Using a different approach for fullscreen element
st.markdown(
f"""
<style>
.full-screen-container {{
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
z-index: -1;
}}
</style>
<div class="full-screen-container">
{js_code}
</div>
""", unsafe_allow_html=True)
if __name__ == "__main__":
create_brain_animation_app() |