document.addEventListener("DOMContentLoaded", function () { const canvas = document.createElement("canvas"); canvas.style.position = "fixed"; canvas.style.top = "0"; canvas.style.left = "0"; canvas.style.pointerEvents = "none"; canvas.style.zIndex = "9999"; document.body.appendChild(canvas); const ctx = canvas.getContext("2d"); let width = window.innerWidth + 100; let height = window.innerHeight; canvas.width = width; canvas.height = height; const flakes = []; // Загружаем изображения для снежинок const snowflakeImages = ["/sneg.png", "/sneg2.png"]; const snowflakes = []; let img1 = new Image(); img1.src = snowflakeImages[0]; let img2 = new Image(); img2.src = snowflakeImages[1]; // Создаем снежинку с отклонением по горизонтали function createFlake() { const randomImage = Math.random() > 0.5 ? img1 : img2; // Выбираем случайное изображение return { x: Math.random() * width, y: Math.random() * height * 0.5, // Появление снежинок в верхней половине экрана image: randomImage, // Присваиваем изображение width: 13 + Math.random() * 5, // Ширина изображения снежинки height: 13 + Math.random() * 5, // Высота изображения снежинки speed: Math.random() * 5 + 0.5, // Скорость падения direction: (Math.random() - 0.5) * 2, // Направление горизонтального отклонения (-1 до 1) drift: Math.random() * 0.5 - 0.1, // Медленное горизонтальное отклонение со временем }; } // Рисуем снежинки function drawFlakes() { ctx.clearRect(0, 0, width, height); // Очистить экран // Рисуем падающие снежинки flakes.forEach((flake) => { ctx.drawImage(flake.image, flake.x, flake.y, flake.width, flake.height); }); } // Двигаем снежинки с эффектом отскока от краев function moveFlakes() { flakes.forEach((flake, index) => { flake.y += flake.speed; // Падение вниз flake.x += flake.direction + flake.drift; // Горизонтальное отклонение // Отскок при достижении левого или правого края экрана if (flake.x < 0 || flake.x > width) { flake.direction = -flake.direction; // Меняем направление на противоположное // Плавное возвращение к центру экрана flake.x = Math.min(Math.max(flake.x, 0), width); } // Если снежинка выходит за нижнюю границу экрана, перемещаем её обратно в верхнюю часть if (flake.y > height) { flake.y = -flake.height; // Переходит в верхнюю часть flake.x = Math.random() * width; // Новая случайная позиция по горизонтали } }); // Добавляем новые снежинки, чтобы поддерживать их количество while (flakes.length < 100) { // Поддерживаем количество снежинок flakes.push(createFlake()); } } // Анимация function loop() { drawFlakes(); moveFlakes(); requestAnimationFrame(loop); } // Инициализация снежинок for (let i = 0; i < 100; i++) { flakes.push(createFlake()); } // Адаптация к изменению размера окна window.addEventListener("resize", () => { width = window.innerWidth + 100; height = window.innerHeight; canvas.width = width; canvas.height = height; }); loop(); });
Flowers
Flowers

Our company prepares premium interior design projects for you, taking into account your wishes. Our team arranges the latest trendy design styles according to your wishes. Our designers determine the ideal combination of materials and help you choose color options. Thanks to the sketches and computer models prepared by our specialists, the clients of our company prepare the exterior of their future houses and the construction work in the exact way they want.

"Molding Baku" specialists can prepare and select any interior detail in the style you are interested in. We offer you products based on the latest fashionable concepts in different formats with the Designers we cooperate with.

 

© Molding. All rights reserved