awacke1 commited on
Commit
1e8c24a
·
verified ·
1 Parent(s): 2750343

Delete backup2.app.py

Browse files
Files changed (1) hide show
  1. backup2.app.py +0 -100
backup2.app.py DELETED
@@ -1,100 +0,0 @@
1
- import streamlit as st
2
-
3
- def create_animation_app():
4
- st.title("Animated Spiral Creature")
5
-
6
- # JavaScript code for the animation
7
- js_code = """
8
- <canvas id="animationCanvas"></canvas>
9
-
10
- <script>
11
- const canvas = document.getElementById('animationCanvas');
12
- const ctx = canvas.getContext('2d');
13
-
14
- // Set canvas size
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
- // Create shifting colors based on position and time
40
- const hue = (Math.sin(t/2) * 360 + x/3 + y/3) % 360;
41
- const saturation = 70 + Math.sin(t) * 30;
42
- const lightness = 50 + Math.cos(t/2) * 20;
43
- return `hsla(${hue}, ${saturation}%, ${lightness}%, 0.5)`;
44
- }
45
-
46
- function draw() {
47
- // Clear canvas with a fade effect
48
- ctx.fillStyle = 'rgba(0, 0, 0, 0.1)';
49
- ctx.fillRect(0, 0, canvas.width, canvas.height);
50
-
51
- ctx.lineWidth = 1.5;
52
-
53
- for(let y = 99; y < 300; y += 4) {
54
- for(let x = 99; x < 300; x += 2) {
55
- const [px, py] = a(x, y);
56
- const color = getColor(x, y, t);
57
-
58
- ctx.strokeStyle = color;
59
- ctx.beginPath();
60
- ctx.moveTo(px, py);
61
- ctx.lineTo(px + 1, py + 1); // Make points slightly larger
62
- ctx.stroke();
63
- }
64
- }
65
-
66
- t += Math.PI / 120; // Slowed down the animation slightly
67
- requestAnimationFrame(draw);
68
- }
69
-
70
- // Ensure canvas is cleared on start
71
- ctx.fillStyle = 'black';
72
- ctx.fillRect(0, 0, canvas.width, canvas.height);
73
-
74
- // Start the animation
75
- draw();
76
- </script>
77
- """
78
-
79
- # CSS to center the canvas and ensure proper display
80
- css = """
81
- <style>
82
- canvas {
83
- display: block;
84
- margin: auto;
85
- background: black;
86
- }
87
- .stApp {
88
- background-color: black;
89
- }
90
- </style>
91
- """
92
-
93
- # Combine CSS and JavaScript
94
- html_content = css + js_code
95
-
96
- # Display using st.components.v1.html
97
- st.components.v1.html(html_content, height=450)
98
-
99
- if __name__ == "__main__":
100
- create_animation_app()