-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAiEvol.html
More file actions
127 lines (97 loc) · 3.67 KB
/
Copy pathAiEvol.html
File metadata and controls
127 lines (97 loc) · 3.67 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fading Shapes Art Generator with Video Background</title>
<style>
body {
margin: 0;
overflow: hidden;
}
#videoContainer {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1; /* Place the video behind the canvas */
}
video {
object-fit: cover;
width: 100%;
height: 100%;
}
canvas {
display: block;
}
</style>
</head>
<body>
<div id="videoContainer">
<video autoplay muted loop>
<!-- Replace the following line with the actual path to your video -->
<source src="" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<canvas id="artCanvas"></canvas>
<script>
// Function to generate random art with fading effect
function generateFadingArt() {
const canvas = document.getElementById('artCanvas');
const ctx = canvas.getContext('2d');
// Set canvas dimensions to fill the window
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
// Clear the canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Generate random shapes with fading effect
const numShapes = Math.floor(Math.random() * 10) + 5;
for (let i = 0; i < numShapes; i++) {
const x = Math.random() * canvas.width;
const y = Math.random() * canvas.height;
const radius = Math.random() * 50;
const color = getRandomColor();
const fadeInDuration = 1000; // milliseconds
fadeShapeIn(ctx, x, y, radius, color, fadeInDuration);
}
}
// Function to fade in a shape
function fadeShapeIn(ctx, x, y, radius, color, fadeInDuration) {
const startTimestamp = Date.now();
function drawFrame() {
const currentTimestamp = Date.now();
const elapsed = currentTimestamp - startTimestamp;
const alpha = Math.min(1, elapsed / fadeInDuration);
ctx.globalAlpha = alpha;
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
ctx.closePath();
ctx.globalAlpha = 1; // Reset global alpha for other shapes
if (elapsed < fadeInDuration) {
requestAnimationFrame(drawFrame);
}
}
requestAnimationFrame(drawFrame);
}
// Function to generate a random color
function getRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
// Generate fading art every 5 seconds (5000 milliseconds)
setInterval(generateFadingArt, 5000);
// Initial generation when the page loads
generateFadingArt();
// Resize canvas when the window is resized
window.addEventListener('resize', generateFadingArt);
</script>
</body>
</html>