Skip to content

Generate multiple configurable sine waves

License

Notifications You must be signed in to change notification settings

krekhovetskyi/sine-waves

Repository files navigation

sine-waves.js

Generator multiple configurable sine waves

Build Status Coverage Status Codacy Badge Dev Dependencies Release

Basic Usage

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;
    }
  }
});

License

SineWaves is open-sourced software licensed under the MIT license

Release Histort

  • v0.1.0 - Initial Release

About

Generate multiple configurable sine waves

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.9%
  • HTML 8.1%