-
Notifications
You must be signed in to change notification settings - Fork 0
/
cc3.html
89 lines (80 loc) · 2.87 KB
/
cc3.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas Art</title>
<style>
body {
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
height: 100vh;
background: linear-gradient(to bottom right, #87CEEB, #FF7F50); /* Nice linear gradient background */
}
canvas {
border: 10px solid rgba(255, 255, 255, 0.5); /* Glassmorphic border */
border-radius: 20px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5); /* Glassmorphic shadow */
}
#windSpeed {
margin-top: 20px;
font-size: 20px;
}
</style>
</head>
<body>
<canvas id="artCanvas" width="400" height="400"></canvas>
<div id="windSpeed">Wind Speed: <span id="speedValue">0</span> km/h</div>
<script>
const canvas = document.getElementById('artCanvas');
const ctx = canvas.getContext('2d');
const windSpeedDisplay = document.getElementById('speedValue');
const numRects = 10;
const rectSize = canvas.width / numRects;
let time = 0;
let windSpeed = 2; // Initial wind speed in km/h
let increasingSpeed = true; // Flag to track wind speed direction
function updateWindSpeed() {
if (increasingSpeed) {
windSpeed += 1;
if (windSpeed >= 10) {
increasingSpeed = false;
}
} else {
windSpeed -= 1;
if (windSpeed <= 2) {
increasingSpeed = true;
}
}
windSpeedDisplay.textContent = windSpeed.toFixed(2); // Update wind speed display
}
setInterval(updateWindSpeed, 1000); // Update wind speed every second
function draw() {
time += 0.1; // Increment time
const fastTime = time * 2; // Faster animation
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (let i = 0; i < numRects; i++) {
for (let j = 0; j < numRects; j++) {
const x = i * rectSize;
const y = j * rectSize;
const depth = Math.sin((i + j) * 0.1 + fastTime) * 50; // Depth effect with faster animation
const windOffset = Math.sin(fastTime) * (windSpeed / 10); // Wind effect
ctx.fillStyle = `rgba(${i * 25}, ${j * 25}, ${(i + j) * 20}, 0.8)`; // Color based on position
ctx.beginPath();
ctx.moveTo(x + windOffset * 10, y);
ctx.lineTo(x + rectSize + windOffset * 10, y);
ctx.lineTo(x + rectSize + windOffset * 10, y + rectSize);
ctx.lineTo(x + windOffset * 10, y + rectSize - depth);
ctx.closePath();
ctx.fill();
}
}
requestAnimationFrame(draw);
}
draw();
</script>
</body>
</html>