Testlend2 / script.js
flpolprojects's picture
Update script.js
fb2810b verified
raw
history blame
2.86 kB
// Частицы на Canvas
const canvas = document.getElementById('particle-canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const particles = [];
for (let i = 0; i < 100; i++) {
particles.push({
x: Math.random() * canvas.width,
y: Math.random() * canvas.height,
radius: Math.random() * 2 + 1,
speed: Math.random() * 1 + 0.5,
color: `hsl(${Math.random() * 360}, 100%, 50%)`
});
}
function animateParticles() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
particles.forEach(p => {
ctx.beginPath();
ctx.arc(p.x, p.y, p.radius, 0, Math.PI * 2);
ctx.fillStyle = p.color;
ctx.fill();
p.y -= p.speed;
if (p.y < 0) p.y = canvas.height;
});
requestAnimationFrame(animateParticles);
}
animateParticles();
// Нейро-анимация продукта
document.addEventListener('mousemove', (e) => {
const product = document.getElementById('ar-product');
const xAxis = (window.innerWidth / 2 - e.pageX) / 20;
const yAxis = (window.innerHeight / 2 - e.pageY) / 20;
product.style.transform = `perspective(1500px) rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
});
// Голосовое управление и заказ
function orderNow() {
const msg = new SpeechSynthesisUtterance("Revolut активирован. Чистота начинается сейчас.");
window.speechSynthesis.speak(msg);
document.body.style.background = "radial-gradient(circle, #00ffcc, #000)";
setTimeout(() => {
document.body.style.background = "#000";
}, 1000);
}
// Эффекты для подов
function podEffect(element) {
element.style.transform = "translateY(-20px) scale(1.1)";
element.style.boxShadow = "0 0 30px rgba(0, 255, 204, 0.7)";
}
function podReset(element) {
element.style.transform = "translateY(0) scale(1)";
element.style.boxShadow = "none";
}
// Нейро-приветствие
window.addEventListener('load', () => {
if ('speechSynthesis' in window) {
const msg = new SpeechSynthesisUtterance("Добро пожаловать в 2070. Активируй Revolut голосом: скажи 'Начать'.");
window.speechSynthesis.speak(msg);
}
});
if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
recognition.lang = 'ru-RU';
recognition.continuous = true;
recognition.onresult = (event) => {
const command = event.results[event.results.length - 1][0].transcript.toLowerCase();
if (command.includes('начать') || command.includes('активировать')) {
orderNow();
}
};
recognition.start();
}