Generator multiple configurable sine waves
var waves = new SineWaves({
el: document.getElementById('waves'),
speed: 8,
waves: [
{
timeModifier: 1,
lineWidth: 3,
amplitude: 150,
wavelength: 200,
segmentLength: 20,
strokeStyle: 'rgba(255, 255, 255, 0.5)'
},
{
timeModifier: 1,
lineWidth: 2,
amplitude: 150,
wavelength: 100,
strokeStyle: 'rgba(255, 255, 255, 0.3)'
}
],
// Perform any additional initializations here
initialize: function (){
},
// This function is called whenver the window is resized
resizeEvent: function() {
// Here is an example on how to create a gradient stroke
var gradient = this.ctx.createLinearGradient(0, 0, this.width, 0);
gradient.addColorStop(0,"rgba(0, 0, 0, 0)");
gradient.addColorStop(0.5,"rgba(255, 255, 255, 0.5)");
gradient.addColorStop(1,"rgba(0, 0, 0, 0)");
var index = -1;
var length = this.waves.length;
while(++index < length){
this.waves[index].strokeStyle = gradient;
}
}
});
SineWaves is open-sourced software licensed under the MIT license
- v0.1.0 - Initial Release