Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
@@ -1,80 +1,86 @@
|
|
1 |
-
//
|
2 |
-
const canvas = document.getElementById('
|
3 |
const ctx = canvas.getContext('2d');
|
4 |
canvas.width = window.innerWidth;
|
5 |
canvas.height = window.innerHeight;
|
6 |
|
7 |
const particles = [];
|
8 |
-
for (let i = 0; i <
|
9 |
particles.push({
|
10 |
x: Math.random() * canvas.width,
|
11 |
y: Math.random() * canvas.height,
|
12 |
-
radius: Math.random() *
|
13 |
-
|
14 |
-
|
|
|
|
|
15 |
});
|
16 |
}
|
17 |
|
18 |
-
function
|
19 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
20 |
particles.forEach(p => {
|
|
|
21 |
ctx.beginPath();
|
22 |
ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
|
23 |
ctx.fillStyle = p.color;
|
24 |
ctx.fill();
|
25 |
-
p.
|
26 |
-
|
|
|
|
|
|
|
27 |
});
|
28 |
-
requestAnimationFrame(
|
29 |
}
|
30 |
-
|
31 |
|
32 |
-
//
|
33 |
-
document.
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
//
|
41 |
function orderNow() {
|
42 |
-
|
43 |
-
|
44 |
-
document.body.style.background = "radial-gradient(circle, #00ffcc, #000)";
|
45 |
setTimeout(() => {
|
46 |
-
document.body.style.background =
|
47 |
-
},
|
|
|
48 |
}
|
49 |
|
50 |
-
// Эффекты
|
51 |
function podEffect(element) {
|
52 |
-
element.style.transform =
|
53 |
-
element.style.boxShadow =
|
54 |
}
|
55 |
|
56 |
function podReset(element) {
|
57 |
-
element.style.transform =
|
58 |
-
element.style.boxShadow =
|
59 |
}
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
const msg = new SpeechSynthesisUtterance("Добро пожаловать в 2070. Активируй Revolut голосом: скажи 'Начать'.");
|
65 |
-
window.speechSynthesis.speak(msg);
|
66 |
-
}
|
67 |
-
});
|
68 |
-
|
69 |
-
if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
|
70 |
-
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
71 |
-
recognition.lang = 'ru-RU';
|
72 |
-
recognition.continuous = true;
|
73 |
-
recognition.onresult = (event) => {
|
74 |
-
const command = event.results[event.results.length - 1][0].transcript.toLowerCase();
|
75 |
-
if (command.includes('начать') || command.includes('активировать')) {
|
76 |
-
orderNow();
|
77 |
-
}
|
78 |
-
};
|
79 |
-
recognition.start();
|
80 |
}
|
|
|
1 |
+
// Космический фон на Canvas
|
2 |
+
const canvas = document.getElementById('cosmo-canvas');
|
3 |
const ctx = canvas.getContext('2d');
|
4 |
canvas.width = window.innerWidth;
|
5 |
canvas.height = window.innerHeight;
|
6 |
|
7 |
const particles = [];
|
8 |
+
for (let i = 0; i < 200; i++) {
|
9 |
particles.push({
|
10 |
x: Math.random() * canvas.width,
|
11 |
y: Math.random() * canvas.height,
|
12 |
+
radius: Math.random() * 4 + 1,
|
13 |
+
speedX: Math.random() * 0.8 - 0.4,
|
14 |
+
speedY: Math.random() * 0.8 - 0.4,
|
15 |
+
color: `hsl(${Math.random() * 360}, 100%, 80%)`,
|
16 |
+
alpha: Math.random() * 0.5 + 0.5
|
17 |
});
|
18 |
}
|
19 |
|
20 |
+
function animateCosmo() {
|
21 |
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
22 |
particles.forEach(p => {
|
23 |
+
ctx.globalAlpha = p.alpha;
|
24 |
ctx.beginPath();
|
25 |
ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
|
26 |
ctx.fillStyle = p.color;
|
27 |
ctx.fill();
|
28 |
+
p.x += p.speedX;
|
29 |
+
p.y += p.speedY;
|
30 |
+
p.alpha = Math.sin(Date.now() * 0.001 + p.x) * 0.5 + 0.5;
|
31 |
+
if (p.x < 0 || p.x > canvas.width) p.speedX *= -1;
|
32 |
+
if (p.y < 0 || p.y > canvas.height) p.speedY *= -1;
|
33 |
});
|
34 |
+
requestAnimationFrame(animateCosmo);
|
35 |
}
|
36 |
+
animateCosmo();
|
37 |
|
38 |
+
// Управление продуктом (ПК: мышь, мобильные: сенсор)
|
39 |
+
const product = document.getElementById('cosmo-product');
|
40 |
+
if ('ontouchstart' in window) {
|
41 |
+
let touchStartX = 0, touchStartY = 0;
|
42 |
+
product.addEventListener('touchstart', (e) => {
|
43 |
+
touchStartX = e.touches[0].clientX;
|
44 |
+
touchStartY = e.touches[0].clientY;
|
45 |
+
});
|
46 |
+
product.addEventListener('touchmove', (e) => {
|
47 |
+
const deltaX = (e.touches[0].clientX - touchStartX) / 10;
|
48 |
+
const deltaY = (e.touches[0].clientY - touchStartY) / 10;
|
49 |
+
product.style.transform = `perspective(2500px) rotateY(${deltaX}deg) rotateX(${-deltaY}deg)`;
|
50 |
+
});
|
51 |
+
product.addEventListener('touchend', () => {
|
52 |
+
product.style.transform = 'perspective(2500px) rotateY(0deg) rotateX(0deg)';
|
53 |
+
});
|
54 |
+
} else {
|
55 |
+
document.addEventListener('mousemove', (e) => {
|
56 |
+
const xAxis = (window.innerWidth / 2 - e.pageX) / 10;
|
57 |
+
const yAxis = (window.innerHeight / 2 - e.pageY) / 10;
|
58 |
+
product.style.transform = `perspective(2500px) rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
|
59 |
+
});
|
60 |
+
}
|
61 |
|
62 |
+
// Заказ
|
63 |
function orderNow() {
|
64 |
+
document.body.style.transition = 'background 0.7s';
|
65 |
+
document.body.style.background = 'radial-gradient(circle, #00ffcc, #ff007a, #000)';
|
|
|
66 |
setTimeout(() => {
|
67 |
+
document.body.style.background = '#000';
|
68 |
+
}, 1200);
|
69 |
+
alert('Revolut запущен. Твоя кожа — космос!');
|
70 |
}
|
71 |
|
72 |
+
// Эффекты подов
|
73 |
function podEffect(element) {
|
74 |
+
element.style.transform = 'translateY(-30px) scale(1.2) translateZ(30px)';
|
75 |
+
element.style.boxShadow = '0 0 50px rgba(0, 255, 204, 1)';
|
76 |
}
|
77 |
|
78 |
function podReset(element) {
|
79 |
+
element.style.transform = 'translateY(0) scale(1) translateZ(0)';
|
80 |
+
element.style.boxShadow = 'none';
|
81 |
}
|
82 |
|
83 |
+
function podTouch(element) {
|
84 |
+
element.classList.add('active');
|
85 |
+
setTimeout(() => element.classList.remove('active'), 700);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|