#hex-bg {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.hex {
position: absolute;
width: 20px;
height: 20px;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 20px solid #00ff00; /* Change the color here to green */
transform: rotate(120deg);
}
document.addEventListener("mousemove", function(event) {
const mouseX = event.pageX;
const mouseY = event.pageY;
const hexBg = document.getElementById("hex-bg");
hexBg.innerHTML = "";
const hexWidth = 30;
const hexHeight = 40;
const hexRows = Math.ceil(window.innerHeight / hexHeight);
const hexCols = Math.ceil(window.innerWidth / hexWidth);
for (let row = 0; row < hexRows; row++) {
for (let col = 0; col < hexCols; col++) {
const hex = document.createElement("div");
hex.classList.add("hex");
const x = col * hexWidth + (row % 2 ? hexWidth / 2 : 0);
const y = row * hexHeight;
hex.style.top = y + "px";
hex.style.left = x + "px";
hex.style.transform = `translate(${mouseX - window.innerWidth / 2}px, ${mouseY - window.innerHeight / 2}px)`;
hexBg.appendChild(hex);
}
}
});
top of page
bottom of page