/    Sign up×
Community /Pin to ProfileBookmark

Use linear-gradient colors in Js

I would like to know how I can apply linear-gradient to a script I found from [wavesurfer-js](https://wavesurfer-js.org/example/rounded-bars/index.html) I want to apply to the progressColor, I tried this:

`var wavesurfer = {};
var color_1 = ‘#D16BA5’;
var color_2 = ‘#86A8E7’;
var color_3 = ‘#5FFBF1’;

var wavesurfer = WaveSurfer.create({
container: document.querySelector(‘#waveform’),
waveColor: ‘#D9DCFF’,
progressColor: ‘linear-gradient(to right, ‘+ color_1 +’, ‘+ color_2 +’, ‘+ color_3 +’)’,
//or progressColor: ‘linear-gradient(to right, ‘+ color_1.value +’, ‘+ color_2.value +’, ‘+ color_3.value +’)’,
cursorColor: ‘#4353FF’,
barWidth: 3,
barRadius: 3,
cursorWidth: 1,
height: 200,
barGap: 3
});`
But it does not apply it only turns the progressColor black. Any help? Thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumDec 31.2019 — A linear gradient is not a color:

https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
The linear-gradient() CSS function creates an image consisting of a progressive transition between two or more colors along a straight line. Its result is an object of the <gradient> data type, which is a special kind of <image>.[/quote]
×

Success!

Help @Ucn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...