Creates a gaussian blur effect background using a canvas element.
> ## Note
>
> This fork is aiming to publish the project to npm. So you can install with:
>
> ``shell`
> npm install gaussian-background-generator
>
>
> Also benefit:
>
> 1. ESM
> 2. TypeScript
A script which creates a gaussian blur effect background using a canvas element. The effect is similar to that seen in various gaussian background images, however, this script generates the effect dynamically and includes a pleasant animation.
Script example (http://projects.foxx.io/gaussian/).
`javascript
var element = document.getElementById('element');
var background = GaussianBackground(element, layers, options);
`
The layers parameter requires an array/object of display layers using the following syntax:
`javascript
var layers = [
{ orbs : 2, radius : 130, maxVelocity : 1, color : '#333333', columns : 0, rows : 0 },
{ color : '#000000' }
];
OR
var layers = {
0 : { orbs : 2, radius : 130, maxVelocity : 1, color : '#333333', columns : 0, rows : 0 },
1 : { color : '#000000' }
};
`
The parameters 'columns' and 'rows' can be used to split the layer orbs into columns and rows to encourage more consistent background generation.
All avalible options are:
`javascript`
var options = {
debug : false, // Only available in the debug version
blur : true,
blurRadius : 50,
blurMethod : 'stackblur|fastblur|integralblur|stackboxblur',
blurIterations : 1,
animation : true,
fpsCap : 20,
renderWidth : 320,
renderHeight : 130
};
The created object has a number of public methods:
`javascript
var background = GaussianBackground(element, layers, options);
// Pauses the animation
background.pause();
// Play the animation
background.play();
// Recalculate the current layers
background.refreshLayers();
// Pass an array of new layers to be rendered
background.updateLayers(layers);
// Update the options of the object
background.updateOptions(options);
``
Special thanks to Mario Klingemann for creating the exceptional StackBlur plugin used in this project.