Skip to content

jsem-nerad/DotWave.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotWave.js

Preview screenshot
A lightweight JavaScript library that creates interactive dot backgrounds

Report a Bug · Request a Feature

Features

  • Dots react smoothly to cursor movements
  • Depth perception with parallax effect
  • Fully customizable (colors, sizes, behavior)
  • Responsive design
  • No dependencies
  • Lightweight

Installation

Direct Download

Download the library here from the src folder and include it in your HTML:

<script src="dotwave.js"></script>

or you can use it remotely like this:

<script src="https://dotwave.vojtikdortik.eu/src/dotwave.js"></script>

Basic Usage

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>DotWave Basic Example</title> 
    <style> body {height: 100vh;} </style>
</head> 
<body> 
    <script src="https://dotwave.vojtikdortik.eu/src/dotwave.js"></script>
    <script>
        // Initialize with default options
        const dotwave = new DotWave({container: 'body'});
    </script>
</body> 
</html> 

Configuration Options

const dotwave = new DotWave({
    container: 'body',           // Container selector or DOM element
    numDots: 200,                // Number of dots
    dotColor: 'white',           // Dot color (CSS color)
    backgroundColor: 'black',    // Background color
    dotMinSize: 0.5,             // Minimum dot size
    dotMaxSize: 2.5,             // Maximum dot size
    dotMinOpacity: 0.5,          // Minimum dot opacity
    dotMaxOpacity: 1,            // Maximum dot opacity
    influenceRadius: 150,        // Mouse influence radius
    influenceStrength: 0.08,     // Mouse influence strength
    randomFactor: 0.03,          // Random movement factor
    friction: 0.97,              // Movement friction
    maxSpeed: 3,                 // Maximum dot speed
    responsive: true,            // Automatically resize with container
    zIndex: -1                   // Canvas z-index
});

Methods

// Initialize
const dotwave = new DotWave(options);

// Pause animation
dotwave.pause();

// Resume animation
dotwave.resume();

// Update options
dotwave.updateOptions({
    dotColor: 'blue',
    numDots: 300
});

// Clean up when done
dotwave.destroy();

Contributing

Contributions are welcome! Please feel free to submit a pull request or an issue.

About

A JavaScript library for making cool star effect reacting to cursor

Topics

Resources

License

Stars

Watchers

Forks