An enhanced sine wave generator tailored for web applications, offering advanced features for creating dynamic, visually captivating sine waves. Ideal for educational tools, music production software, and creative web projects.
Install using npm for easy incorporation into your project:
npm install sine-wave-generator
import {SineWaveGenerator} from 'sine-wave-generator';
const waves = [/* array of Wave configs */];
const generator = new SineWaveGenerator({
el: '#sineCanvas',
waves
});
generator.start();
Check out the examples directory for a complete set of usage examples, including:
- Basic single wave
- Multiple waves configuration
- Interactive mouse movement
- Dynamic wave management
Initializes the sine wave generator with the provided options.
Type: object
Type: HTMLElement|string
The canvas element or selector for the canvas.
Type: Wave[]
Array of Wave
instances to be animated.
Represents a single wave configuration.
Type: object
Configuration object for the wave.
Starts the animation of waves.
Stops the animation of waves.
Adds a new wave to the animation.
Removes a wave from the animation.
All modern browsers, including Chrome, Firefox, Safari, Edge. Falls back to 2D canvas.
You can customize the waves by changing their configuration options, such as amplitude
, wavelength
, speed
, and strokeStyle
.
Yes, the SineWaveGenerator
supports mouse interaction to disturb the waves. You can also extend its functionality by adding event listeners to the canvas.
Check out the CHANGELOG for the latest updates and changes to the project.
I would like to express my appreciation to sine-waves code repository and its creator, Isaac Suttell, for serving as an incredible source of inspiration.
Pull requests welcome! Please check out the contribution guidelines.
Apache-2.0 © Copyright 2024 Sine Wave Generator. All rights reserved.