
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@dragonspark/hikari-effects
Advanced tools
Ready-to-use visual effects built on top of the @dragonspark/hikari WebGL framework.
Ready-to-use visual effects built on top of the @dragonspark/hikari WebGL framework.
npm install @dragonspark/hikari-effects @dragonspark/hikari
# or
yarn add @dragonspark/hikari-effects @dragonspark/hikari
Note: @dragonspark/hikari is a peer dependency and must be installed alongside this package.
A beautiful, animated gradient background effect with morphing colors and shapes.
import { MorphGradient } from '@dragonspark/hikari-effects';
// Initialize the gradient on a canvas element
const gradient = new MorphGradient({
selector: '#canvas',
baseColor: '#ff0000',
waveColors: ['#00ff00', '#0000ff', '#ffff00']
});
You can define gradient colors using CSS variables:
:root {
--gradient-color-1: #ff0000;
--gradient-color-2: #00ff00;
--gradient-color-3: #0000ff;
--gradient-color-4: #ffff00;
}
const gradient = new MorphGradient({
selector: '#canvas'
});
You can also pass CSS variables directly:
const gradient = new MorphGradient({
selector: '#canvas',
baseColor: 'var(--gradient-color-1)',
waveColors: [
'var(--gradient-color-2)',
'var(--gradient-color-3)',
'var(--gradient-color-4)'
]
});
If CSS variables are not available or parsing fails, the component will fall back to these default values:
// Default base color
const defaultBaseColor = '#a960ee'; // Purple
// Default wave colors
const defaultWaveColors = [
'#ff333d', // Red
'#90e0ff', // Light blue
'#ffcb57' // Yellow
];
const gradient = new MorphGradient({
selector: '#canvas',
amplitude: 320, // Wave amplitude
seed: 5, // Random seed
freqX: 14e-5, // X-axis frequency
freqY: 29e-5, // Y-axis frequency
freqDelta: 1e-5, // Frequency change rate
darkenTop: true // Darken the top of the gradient
});
// Pause animation
gradient.pause();
// Resume animation
gradient.play();
// Update frequency
gradient.updateFrequency(0.001);
// Toggle specific color
gradient.toggleColor(0); // Toggle first color
// Change zoom
gradient.setZoom(1);
// Change rotation
gradient.setRotation(45);
// Change density
gradient.setDensity([0.1, 0.2])
new MorphGradient(options)
options.selector: string - CSS selector for the canvas elementoptions.baseColor: string (optional) - Base color for the gradient. Can be:
options.waveColors: string[] (optional) - Array of wave colors for the gradient. Can be:
options.amplitude: number (optional) - Wave amplitudeoptions.seed: number (optional) - Random seedoptions.freqX: number (optional) - X-axis frequencyoptions.freqY: number (optional) - Y-axis frequencyoptions.freqDelta: number (optional) - Frequency change rateoptions.darkenTop: boolean (optional) - Darken the top of the gradientplay(): Start/resume the animationpause(): Pause the animationupdateFrequency(delta): Update the frequency by the specified deltatoggleColor(index): Toggle the visibility of a color by indexresize(): Resize the gradient to fit the containersetZoom(zoom): Set the zoom level of the gradientsetRotation(rotation): Set the rotation angle in degreessetDensity(density): Set the density of the mesh as [x, y] valuesimport { MorphGradient } from '@dragonspark/hikari-effects';
// Create canvas element
const canvas = document.createElement('canvas');
canvas.id = 'gradient-bg';
document.body.appendChild(canvas);
// Initialize gradient
const gradient = new MorphGradient({
selector: '#gradient-bg',
baseColor: '#3498db',
waveColors: ['#9b59b6', '#e74c3c', '#f1c40f']
});
// Handle window resize
window.addEventListener('resize', () => {
gradient.resize();
});
import { MorphGradient } from '@dragonspark/hikari-effects';
const gradient = new MorphGradient({
selector: '#interactive-gradient'
});
// Toggle colors on click
document.querySelectorAll('.color-toggle').forEach((button, index) => {
button.addEventListener('click', () => {
gradient.toggleColor(index);
});
});
// Pause/play on button click
document.querySelector('#play-pause').addEventListener('click', () => {
if (gradient.conf.playing) {
gradient.pause();
} else {
gradient.play();
}
});
MIT © DragonSpark
FAQs
Ready-to-use visual effects built on top of the @dragonspark/hikari WebGL framework.
The npm package @dragonspark/hikari-effects receives a total of 4 weekly downloads. As such, @dragonspark/hikari-effects popularity was classified as not popular.
We found that @dragonspark/hikari-effects demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.