html波形报告,HTML5 Canvas sine-wave.js 直线/正弦波/锯齿波形

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

var waves = new SineWaves({

el: document.getElementById('waves'),

speed: 4,

width: function() {

return $(window).width();

},

height: function() {

return $(window).height();

},

ease: 'SineInOut',

wavesWidth: '80%',

waves: [{}],

set1: [{

timeModifier: 4,

lineWidth: 2,

amplitude: -100,

wavelength: 0

}, {

timeModifier: 4,

lineWidth: 1,

amplitude: -50,

wavelength: 0

}],

set2: [{

timeModifier: 4,

lineWidth: 2,

amplitude: -100,

wavelength: 25

}, {

timeModifier: 4,

lineWidth: 1,

amplitude: -50,

wavelength: 20

}],

set3: [{

timeModifier: 1,

lineWidth: 2,

amplitude: -180,

wavelength: 50,

type: 'Triangle',

segmentLength: 1

}],

initialize: function() {

this.options.startWaves.call(this, 'set1');

var self = this;

$('.line').on('click', function() {

self.options.startWaves.call(self, 'set1');

});

$('.curve').on('click', function() {

self.options.startWaves.call(self, 'set2');

});

$('.jagged').on('click', function() {

self.options.startWaves.call(self, 'set3');

});

},

startWaves: function(waves) {

this.waves = this.options[waves];

this.options.resizeEvent.call(this);

this.setupWaveFns();

},

// Resize

resizeEvent: function() {

var gradient = this.ctx.createLinearGradient(0, 0, this.width, 0);

gradient.addColorStop(0, "rgba(0,134,141,1)");

var index = -1;

var length = this.waves.length;

while (++index < length) {

this.waves[index].strokeStyle = gradient;

}

// Clean Up

index = void 0;

length = void 0;

gradient = void 0;

}

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值