awacke1 commited on
Commit
57b3cfe
·
verified ·
1 Parent(s): 2ab5bf2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +92 -0
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def create_animation_app():
4
+ st.title("AI Memory Enhancement Visualization")
5
+ st.write("This animation represents how AI might continually remember and build upon what users care about.")
6
+
7
+ # JavaScript code for the animation
8
+ js_code = """
9
+ <canvas id="animationCanvas"></canvas>
10
+
11
+ <script>
12
+ const canvas = document.getElementById('animationCanvas');
13
+ const ctx = canvas.getContext('2d');
14
+
15
+ canvas.width = 400;
16
+ canvas.height = 400;
17
+
18
+ let t = 0;
19
+
20
+ function mag(x, y) {
21
+ return Math.sqrt(x * x + y * y);
22
+ }
23
+
24
+ function a(x, y) {
25
+ const k = x/8 - 25;
26
+ const e = y/8 - 25;
27
+ const d = mag(k, e)**2 / 99;
28
+
29
+ const q = x/3 + k * 0.5 / Math.cos(y*5) * Math.sin(d*d - t);
30
+ const c = d/2 - t/8;
31
+
32
+ const xPos = q * Math.sin(c) + e * Math.sin(d + k - t) + 200;
33
+ const yPos = (q + y/8 + d*9) * Math.cos(c) + 200;
34
+
35
+ return[xPos, yPos];
36
+ }
37
+
38
+ function getColor(x, y, t) {
39
+ const hue = (Math.sin(t/2) * 360 + x/3 + y/3) % 360;
40
+ const saturation = 70 + Math.sin(t) * 30;
41
+ const lightness = 50 + Math.cos(t/2) * 20;
42
+ return `hsla(${hue}, ${saturation}%, ${lightness}%, 0.5)`;
43
+ }
44
+
45
+ function draw() {
46
+ ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
47
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
48
+
49
+ ctx.lineWidth = 1.5;
50
+
51
+ for(let y = 99; y < 300; y += 4) {
52
+ for(let x = 99; x < 300; x += 2) {
53
+ const[px, py] = a(x, y);
54
+ const color = getColor(x, y, t);
55
+
56
+ ctx.strokeStyle = color;
57
+ ctx.beginPath();
58
+ ctx.moveTo(px, py);
59
+ ctx.lineTo(px + 1, py + 1);
60
+ ctx.stroke();
61
+ }
62
+ }
63
+
64
+ t += Math.PI / 120;
65
+ requestAnimationFrame(draw);
66
+ }
67
+
68
+ ctx.fillStyle = 'black';
69
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
70
+ draw();
71
+ </script>
72
+ """
73
+
74
+ css = """
75
+ <style>
76
+ canvas {
77
+ display: block;
78
+ margin: auto;
79
+ background: black;
80
+ }
81
+ .stApp {
82
+ background-color: black;
83
+ }
84
+ </style>
85
+ """
86
+
87
+ html_content = css + js_code
88
+
89
+ st.components.v1.html(html_content, height=450)
90
+
91
+ if __name__ == "__main__":
92
+ create_animation_app()