awacke1's picture
Create app.py
57b3cfe verified
raw
history blame
2.39 kB
import streamlit as st
def create_animation_app():
st.title("AI Memory Enhancement Visualization")
st.write("This animation represents how AI might continually remember and build upon what users care about.")
# JavaScript code for the animation
js_code = """
<canvas id="animationCanvas"></canvas>
<script>
const canvas = document.getElementById('animationCanvas');
const ctx = canvas.getContext('2d');
canvas.width = 400;
canvas.height = 400;
let t = 0;
function mag(x, y) {
return Math.sqrt(x * x + y * y);
}
function a(x, y) {
const k = x/8 - 25;
const e = y/8 - 25;
const d = mag(k, e)**2 / 99;
const q = x/3 + k * 0.5 / Math.cos(y*5) * Math.sin(d*d - t);
const c = d/2 - t/8;
const xPos = q * Math.sin(c) + e * Math.sin(d + k - t) + 200;
const yPos = (q + y/8 + d*9) * Math.cos(c) + 200;
return[xPos, yPos];
}
function getColor(x, y, t) {
const hue = (Math.sin(t/2) * 360 + x/3 + y/3) % 360;
const saturation = 70 + Math.sin(t) * 30;
const lightness = 50 + Math.cos(t/2) * 20;
return `hsla(${hue}, ${saturation}%, ${lightness}%, 0.5)`;
}
function draw() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.lineWidth = 1.5;
for(let y = 99; y < 300; y += 4) {
for(let x = 99; x < 300; x += 2) {
const[px, py] = a(x, y);
const color = getColor(x, y, t);
ctx.strokeStyle = color;
ctx.beginPath();
ctx.moveTo(px, py);
ctx.lineTo(px + 1, py + 1);
ctx.stroke();
}
}
t += Math.PI / 120;
requestAnimationFrame(draw);
}
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, canvas.width, canvas.height);
draw();
</script>
"""
css = """
<style>
canvas {
display: block;
margin: auto;
background: black;
}
.stApp {
background-color: black;
}
</style>
"""
html_content = css + js_code
st.components.v1.html(html_content, height=450)
if __name__ == "__main__":
create_animation_app()