Skip to content
This repository was archived by the owner on Mar 14, 2026. It is now read-only.

Kiran18b/demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ‚ Happy Birthday Animation Website

A beautiful, interactive birthday animation website featuring a starry night sky, animated text, shooting stars, and mobile-responsive design with rotation prompts.

✨ Features

🎨 Visual Effects

  • Starry Night Sky: Animated twinkling stars with layered background
  • Shooting Stars: Random shooting star effects across the canvas
  • Text Animation: "WISH YOU HAPPY BIRTHDAY ANUSHA πŸ’—" animated with particle effects
  • Explosions: Click/tap anywhere to create colorful explosion effects
  • Bear Character: Interactive bear image with hover effects

πŸ“± Mobile Responsiveness

  • Orientation Detection: Automatically detects mobile devices
  • Rotation Prompt: Beautiful animated popup when device is in portrait mode
  • Progressive Unlock: Shows rotation message first, then birthday content after rotating
  • Touch Support: Optimized for touch interactions
  • Responsive Canvas: Adapts to any screen size

🎭 Animations

  • Particle Text: Birthday message forms from animated dots
  • Continuous Effects: Stars twinkle, shooting stars appear randomly
  • Interactive Explosions: Click explosions with physics
  • Smooth Transitions: All animations use requestAnimationFrame for performance

πŸš€ Quick Start

Prerequisites

  • Modern web browser (Chrome, Firefox, Safari, Edge)
  • No server required - runs locally

Installation

  1. Clone or download the project files
  2. Open index.html in your web browser
  3. Enjoy the animation!

File Structure

Happy-Birthday/
β”œβ”€β”€ index.html      # Main HTML structure
β”œβ”€β”€ script.js       # Animation logic and interactions
└── style.css       # Styling and animations

πŸ“– Code Overview

HTML Structure (index.html)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>HAPPY BIRTHDAY ANUSHA</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <canvas id="canvas"></canvas>                    <!-- Main animation canvas -->
  <div id="rotateNotice">                         <!-- Mobile rotation prompt -->
    <div class="overlay">
      <div class="rotate-content">
        <div class="emoji-top">πŸŽ‚ WAIT! πŸŽ‚</div>
        <p class="rotate-message">Please rotate your screen</p>
        <p class="rotate-message">to see the magic ✨</p>
        <div class="phone-icon">πŸ“±</div>
      </div>
    </div>
  </div>
  <img id="bear" src="bear-gif-url" alt="Bear" />  <!-- Bear character -->
  <script src="script.js"></script>
</body>
</html>

JavaScript Architecture (script.js)

Core Components

  • Canvas Setup: Initializes HTML5 canvas with error handling
  • Animation Loop: Main animation loop using requestAnimationFrame
  • State Management: Manages animation states and intervals
  • Event Handlers: Click/touch events for interactions

Key Functions

// Core initialization
checkOrientation()     // Detects mobile orientation
resizeCanvas()         // Handles window resizing
animate()             // Main animation loop

// Animation effects
drawStars()           // Renders twinkling stars
drawShootingStars()   // Renders shooting star effects
createExplosion()     // Creates particle explosions
shootDot()           // Animates text formation

// Text generation
generateCharDots()    // Converts text to particle coordinates
generateAllTargetDots() // Prepares text animation data

Animation States

  • stars[]: Array of star objects with position, size, and opacity
  • shootingStars[]: Array of shooting star objects
  • explosions[]: Array of explosion particles
  • dots[]: Current animated particles
  • targetDotsQueue[]: Target positions for text formation

CSS Styling (style.css)

Layout

  • Full-screen Canvas: Covers entire viewport
  • Night Sky Background: Radial gradient with star patterns
  • Fixed Positioning: Bear and rotation notice positioning

Animations

@keyframes bounce        /* Bouncing emoji animation */
@keyframes pulse-glow    /* Pulsing overlay effect */
@keyframes fade-in-out   /* Text fade animation */
@keyframes rotate-phone  /* Phone rotation animation */

Responsive Design

  • Mobile Detection: Uses JavaScript for orientation checking
  • Touch Optimization: Prevents ghost clicks on mobile
  • Flexible Layout: Adapts to different screen sizes

🎯 Customization

Change the Birthday Message

Edit the fullText array in script.js:

const fullText = ["YOUR CUSTOM MESSAGE HERE"];

Modify Colors

Update the background gradient in style.css:

background: radial-gradient(circle at top, #your-color1 0%, #your-color2 40%, #your-color3 100%);

Adjust Animation Speed

Modify interval timings in script.js:

shootInterval = setInterval(shootDot, 50);        // Text formation speed
shootStarInterval = setInterval(createShootingStar, 1500); // Shooting star frequency

Change Bear Image

Update the src attribute in index.html:

<img id="bear" src="your-image-url.gif" alt="Bear" />

πŸ”§ Technical Details

Browser Compatibility

  • βœ… Chrome 60+
  • βœ… Firefox 55+
  • βœ… Safari 12+
  • βœ… Edge 79+
  • βœ… Mobile browsers (iOS Safari, Chrome Mobile)

Performance Optimizations

  • RequestAnimationFrame: Smooth 60fps animations
  • Canvas Reuse: Single canvas context
  • Efficient Loops: Optimized particle systems
  • Memory Management: Proper cleanup of intervals

Error Handling

  • Canvas context availability checks
  • Image loading error handling
  • Graceful degradation for unsupported features
  • Console logging for debugging

πŸ“± Mobile Features

Orientation Detection

function checkOrientation() {
  const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
  const isPortrait = window.innerHeight > window.innerWidth;

  if (isMobile) {
    if (!hasRotatedToLandscape) {
      if (isPortrait) {
        // Show initial rotation message
        updateRotationMessage("initial");
        showRotationNotice();
      } else {
        // User rotated to landscape - unlock content
        hasRotatedToLandscape = true;
        updateRotationMessage("success");
        setTimeout(() => {
          hideRotationNotice();
          startBirthdayAnimations();
        }, 10000); // 10 second success message
      }
    }
  }
}

Progressive Content Unlock

  • Step 1: Show rotation prompt on mobile (portrait or landscape)
  • Step 2: User rotates to landscape mode
  • Step 3: Show success message briefly
  • Step 4: Unlock and start birthday animations

Touch Events

  • Touch Start: Creates explosions at touch points
  • Prevent Default: Avoids unwanted scrolling/zooming
  • Passive Events: Improves scroll performance

🎨 Animation Details

Star System

  • 300 Stars: Randomly positioned across canvas
  • Twinkling Effect: Opacity animation with sine waves
  • Layered Background: CSS background-image stars

Text Animation

  • Particle System: Text forms from individual dots
  • Physics: Dots "shoot" from bear position to target locations
  • Character-by-Character: Sequential text formation

Explosion Effects

  • 20 Particles: Per explosion event
  • Physics Simulation: Velocity, gravity, and opacity decay
  • Colorful: Random particle colors

πŸš€ Deployment

Local Development

  1. Open index.html directly in browser
  2. No build process required
  3. Hot reload by refreshing browser

Web Server

# Using Python
python -m http.server 8000

# Using Node.js
npx http-server

# Access at http://localhost:8000

GitHub Pages

  1. Upload files to GitHub repository
  2. Enable GitHub Pages in repository settings
  3. Access via https://username.github.io/repository-name

πŸ› Troubleshooting

Common Issues

Canvas not showing:

  • Check browser console for errors
  • Ensure JavaScript is enabled
  • Verify canvas element exists in DOM

Animations not smooth:

  • Check browser performance
  • Reduce particle counts if needed
  • Ensure hardware acceleration is enabled

Mobile rotation notice not appearing:

  • Test on actual mobile device
  • Check device orientation API support
  • Verify user agent detection

Bear image not loading:

  • Check image URL validity
  • Verify internet connection
  • Image will hide automatically on load failure

πŸ“„ License

This project is open source. Feel free to use, modify, and distribute.

πŸ™ Acknowledgments

  • Starry night sky inspired by real night skies
  • Bear character from online GIF resources
  • Animation techniques from HTML5 Canvas tutorials
  • Mobile responsiveness best practices

Happy Birthday Anusha! πŸŽ‚βœ¨

About

IT'S BIRTHDAY

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors