This commit is contained in:
2025-08-06 21:00:51 +02:00
parent 2c8f1bcca0
commit b288b29e35
6 changed files with 464 additions and 1050 deletions
@@ -1,6 +1,3 @@
// src/assets/backgrounds/Background.jsx
// Kockás háttér, ami a mousemovera reagál
import React, { useEffect, useState } from "react"
import { motion } from "framer-motion"
@@ -13,8 +10,8 @@ const Background = () => {
const updateGrid = () => {
const width = window.innerWidth
const height = window.innerHeight
const cols = Math.max(8, Math.floor(width / 100)) // 100px-es cellák
const rows = Math.max(5, Math.floor(height / 100)) // 100px-es cellák
const cols = Math.max(8, Math.floor(width / 100))
const rows = Math.max(5, Math.floor(height / 100))
setGridSize({ cols, rows })
}
@@ -37,26 +34,19 @@ const Background = () => {
const newCol = Math.floor(Math.random() * gridSize.cols)
const newRow = Math.floor(Math.random() * gridSize.rows)
setPath((prevPath) => {
const newPath = [...prevPath, { col: newCol, row: newRow, opacity: 1 }] // Új pont hozzáadása
if (newPath.length > 10) {
newPath.shift() // Max 10 pont az útvonalon
}
const newPath = [...prevPath, { col: newCol, row: newRow, opacity: 1 }]
if (newPath.length > 10) newPath.shift()
return newPath
})
}, 500) // Új pont hozzáadása minden 500ms-ben
}, 500)
// Az útvonal pontjainak fokozatos eltűnése
const fadeInterval = setInterval(() => {
setPath(
(prevPath) =>
prevPath
.map((point) => ({
...point,
opacity: Math.max(0, point.opacity - 0.05), // Fokozatosan csökkentjük az opacity-t
}))
.filter((point) => point.opacity > 0) // Eltávolítjuk a teljesen eltűnt pontokat
setPath((prevPath) =>
prevPath
.map((point) => ({ ...point, opacity: Math.max(0, point.opacity - 0.05) }))
.filter((point) => point.opacity > 0)
)
}, 100) // Opacity frissítése minden 100ms-ben
}, 100)
return () => {
clearInterval(interval)
@@ -82,9 +72,8 @@ const Background = () => {
const dx = cellX - mousePos.x
const dy = cellY - mousePos.y
const distance = Math.sqrt(dx * dx + dy * dy)
const distanceFactor = Math.max(0, 1 - distance / 300) // Egér hatótávolsága
const distanceFactor = Math.max(0, 1 - distance / 300)
// Az útvonalban lévő pontok opacitása
const pathPoint = path.find((p) => p.col === col && p.row === row)
const pathOpacity = pathPoint ? pathPoint.opacity : 0
@@ -93,10 +82,10 @@ const Background = () => {
key={i}
className="w-full h-full bg-white rounded-lg"
animate={{
opacity: 0.05 + distanceFactor * 0.2 + pathOpacity * 0.5, // Kombinált opacitás
scale: 1 + distanceFactor * 0.05 + pathOpacity * 0.1, // Kombinált skálázás
opacity: 0.05 + distanceFactor * 0.2 + pathOpacity * 0.5,
scale: 1 + distanceFactor * 0.05 + pathOpacity * 0.1,
}}
transition={{ duration: 0.5, ease: "easeOut" }} // Lassú és sima átmenet
transition={{ duration: 0.5, ease: "easeOut" }}
/>
)
})}