Wavesurfer.js: Gradient for progressColor?

Created on 25 Mar 2015  路  3Comments  路  Source: katspaugh/wavesurfer.js

Is it possible to render a gradient for the progressColor?

Most helpful comment

Yes, it's actually working. Use this code:

var linGrad = document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 1000, 128);
linGrad.addColorStop(0, '#8ED6FF'); 
linGrad.addColorStop(1, '#004CB3');

var wavesurfer = WaveSurfer.create({
  container: '#waveform',
  progressColor: linGrad
});

See live demo here: http://plnkr.co/edit/L99eTSvAkuVJDOXtdCDu?p=preview

All 3 comments

Naively I'm going to say this is possible to do with https://developer.mozilla.org/en-US/docs/Web/API/CanvasGradient

It might be possible to pass a Canvas gradient object as progressColor, but I'm not sure. Try it.

Yes, it's actually working. Use this code:

var linGrad = document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 1000, 128);
linGrad.addColorStop(0, '#8ED6FF'); 
linGrad.addColorStop(1, '#004CB3');

var wavesurfer = WaveSurfer.create({
  container: '#waveform',
  progressColor: linGrad
});

See live demo here: http://plnkr.co/edit/L99eTSvAkuVJDOXtdCDu?p=preview

Was this page helpful?
0 / 5 - 0 ratings