constellations / index.html
okochilraphael's picture
Create an interactive landing page that looks like a starry galaxy. The central glowing star should be named “Felly Ndinda” surrounded by a slightly smaller star named “Raphael Okochil”. The galaxy should be filled with constellations made of affectionate words, like “princess,” “my love,” and “beautiful.”
edfe2e9 verified
Raw History Blame Contribute Delete
12.6 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Starry Galaxy for Felly & Raphael</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
<style>
body {
margin: 0;
overflow: hidden;
font-family: 'Arial', sans-serif;
}
#galaxy-container {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
.star {
position: absolute;
border-radius: 50%;
pointer-events: none;
animation: twinkle 3s infinite alternate;
}
.constellation {
position: absolute;
color: white;
font-weight: bold;
text-shadow: 0 0 10px currentColor;
pointer-events: none;
opacity: 0;
transition: opacity 0.5s;
}
.constellation-line {
position: absolute;
height: 2px;
background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.5), rgba(255,255,255,0));
transform-origin: 0 0;
pointer-events: none;
}
.zoom-controls {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 100;
display: flex;
gap: 10px;
}
.zoom-btn {
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(255,255,255,0.2);
backdrop-filter: blur(5px);
display: flex;
align-items: center;
justify-content: center;
color: white;
cursor: pointer;
transition: all 0.3s;
}
.zoom-btn:hover {
background: rgba(255,255,255,0.4);
}
.music-control {
position: fixed;
bottom: 20px;
left: 20px;
z-index: 100;
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(255,255,255,0.2);
backdrop-filter: blur(5px);
display: flex;
align-items: center;
justify-content: center;
color: white;
cursor: pointer;
transition: all 0.3s;
}
.music-control:hover {
background: rgba(255,255,255,0.4);
}
@keyframes twinkle {
0% { opacity: 0.5; }
100% { opacity: 1; }
}
.title {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 3rem;
text-align: center;
z-index: 10;
text-shadow: 0 0 20px rgba(255,255,255,0.7);
pointer-events: none;
}
.subtitle {
position: fixed;
top: 60%;
left: 50%;
transform: translate(-50%, -50%);
color: rgba(255,255,255,0.8);
font-size: 1.5rem;
text-align: center;
z-index: 10;
text-shadow: 0 0 10px rgba(255,255,255,0.5);
pointer-events: none;
}
</style>
</head>
<body>
<div id="galaxy-container"></div>
<div class="title">Felly Ndinda</div>
<div class="subtitle">Raphael Okochil</div>
<div class="zoom-controls">
<div class="zoom-btn" id="zoom-in">
<i data-feather="plus"></i>
</div>
<div class="zoom-btn" id="zoom-out">
<i data-feather="minus"></i>
</div>
</div>
<div class="music-control" id="music-control">
<i data-feather="music"></i>
</div>
<audio id="bg-music" loop>
<source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
</audio>
<script>
// Initialize Vanta.js galaxy background
const vantaEffect = VANTA.GLOBE({
el: "#galaxy-container",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x9d65c9,
backgroundColor: 0x0,
size: 0.8,
points: 6.00
});
// Create stars and constellations
const container = document.getElementById('galaxy-container');
const colors = ['#ff9ff3', '#feca57', '#ff6b6b', '#48dbfb', '#1dd1a1', '#f368e0'];
let zoomLevel = 1;
let musicPlaying = false;
const music = document.getElementById('bg-music');
const musicControl = document.getElementById('music-control');
// Constellation words by level
const constellations = {
1: ["Princess", "Queen", "My Love", "Beautiful", "Angel", "Sunshine", "Darling", "My Star", "Treasure", "Soulmate"],
2: ["Light of My Life", "Forever Mine", "Magic", "Dream Girl", "Sweetheart", "Jewel", "Blossom", "Pearl", "Rose", "Destiny"],
3: ["Heartbeat", "Glow", "My Universe", "Starlight", "Honey", "Miracle", "Hope", "Joy", "Melody", "Moonlight"],
4: ["Always & Forever", "My Safe Place", "My Favorite Hello", "My Forever Person", "You & Me, Always", "I Found Home in You", "Eternity With You", "My Galaxy is You"]
};
// Create stars
function createStars() {
// Main stars
createStar('Felly Ndinda', 0, 0, 20, '#ff9ff3');
createStar('Raphael Okochil', 100, 50, 15, '#feca57');
// Random stars
for (let i = 0; i < 100; i++) {
const x = (Math.random() - 0.5) * 2000;
const y = (Math.random() - 0.5) * 2000;
const size = Math.random() * 3 + 1;
const color = colors[Math.floor(Math.random() * colors.length)];
createStar('', x, y, size, color);
}
}
function createStar(name, x, y, size, color) {
const star = document.createElement('div');
star.className = 'star';
star.style.width = `${size}px`;
star.style.height = `${size}px`;
star.style.left = `calc(50% + ${x}px)`;
star.style.top = `calc(50% + ${y}px)`;
star.style.backgroundColor = color;
star.style.boxShadow = `0 0 ${size*2}px ${size}px ${color}`;
star.style.animationDelay = `${Math.random() * 3}s`;
if (name) {
star.setAttribute('data-name', name);
star.style.boxShadow = `0 0 ${size*4}px ${size*2}px ${color}`;
}
container.appendChild(star);
}
// Create constellations
function createConstellations() {
for (const level in constellations) {
const words = constellations[level];
const count = words.length;
const radius = 200 + (level * 100);
for (let i = 0; i < count; i++) {
const angle = (i / count) * Math.PI * 2;
const x = Math.cos(angle) * radius;
const y = Math.sin(angle) * radius;
// Create word
const word = document.createElement('div');
word.className = 'constellation';
word.textContent = words[i];
word.style.color = colors[i % colors.length];
word.style.left = `calc(50% + ${x}px)`;
word.style.top = `calc(50% + ${y}px)`;
word.style.fontSize = `${1.5 - (level * 0.2)}rem`;
word.setAttribute('data-level', level);
container.appendChild(word);
// Create lines (connect to next word)
if (i < count - 1) {
const nextAngle = ((i + 1) / count) * Math.PI * 2;
const nextX = Math.cos(nextAngle) * radius;
const nextY = Math.sin(nextAngle) * radius;
createConstellationLine(x, y, nextX, nextY, colors[i % colors.length], level);
}
}
}
}
function createConstellationLine(x1, y1, x2, y2, color, level) {
const dx = x2 - x1;
const dy = y2 - y1;
const length = Math.sqrt(dx * dx + dy * dy);
const angle = Math.atan2(dy, dx) * 180 / Math.PI;
const line = document.createElement('div');
line.className = 'constellation-line';
line.style.width = `${length}px`;
line.style.left = `calc(50% + ${x1}px)`;
line.style.top = `calc(50% + ${y1}px)`;
line.style.transform = `rotate(${angle}deg)`;
line.style.opacity = '0';
line.setAttribute('data-level', level);
container.appendChild(line);
}
// Update visibility based on zoom level
function updateVisibility() {
const constellations = document.querySelectorAll('.constellation, .constellation-line');
constellations.forEach(el => {
const level = parseInt(el.getAttribute('data-level'));
el.style.opacity = zoomLevel >= level ? '1' : '0';
});
// Scale the container to simulate zoom
container.style.transform = `scale(${zoomLevel})`;
}
// Event listeners
document.getElementById('zoom-in').addEventListener('click', () => {
if (zoomLevel < 4) {
zoomLevel += 0.5;
updateVisibility();
}
});
document.getElementById('zoom-out').addEventListener('click', () => {
if (zoomLevel > 1) {
zoomLevel -= 0.5;
updateVisibility();
}
});
musicControl.addEventListener('click', () => {
musicPlaying = !musicPlaying;
if (musicPlaying) {
music.play();
musicControl.innerHTML = '<i data-feather="pause"></i>';
} else {
music.pause();
musicControl.innerHTML = '<i data-feather="music"></i>';
}
feather.replace();
});
// Handle touch events for pinch zoom
let initialDistance = null;
container.addEventListener('touchstart', (e) => {
if (e.touches.length === 2) {
initialDistance = Math.hypot(
e.touches[0].clientX - e.touches[1].clientX,
e.touches[0].clientY - e.touches[1].clientY
);
}
});
container.addEventListener('touchmove', (e) => {
if (e.touches.length === 2 && initialDistance) {
const currentDistance = Math.hypot(
e.touches[0].clientX - e.touches[1].clientX,
e.touches[0].clientY - e.touches[1].clientY
);
if (currentDistance > initialDistance + 50) {
// Zoom in
if (zoomLevel < 4) {
zoomLevel += 0.1;
updateVisibility();
}
initialDistance = currentDistance;
} else if (currentDistance < initialDistance - 50) {
// Zoom out
if (zoomLevel > 1) {
zoomLevel -= 0.1;
updateVisibility();
}
initialDistance = currentDistance;
}
}
});
container.addEventListener('touchend', () => {
initialDistance = null;
});
// Initialize
createStars();
createConstellations();
updateVisibility();
feather.replace();
</script>
</body>
</html>