vendredi 5 mars 2021

rainbow.js randomize from a list on load?

I have this rainbow changing the background color of a div:

var numberOfItems = 40;
var rainbow = new Rainbow();
rainbow.setNumberRange(1, numberOfItems);
rainbow.setSpectrum('#e8e2d1', '2b2928');
var s = '';
var colors = [];
for (var i = 1; i <= numberOfItems; i++) {
    var hexColour = '#' +rainbow.colourAt(i);
    colors.push(hexColour)

}

was wondering if there was a way to make it that the spectrum (in this case '#e8e2d1', '2b2928') is randomized from 2-3 options so that each time the page is loaded the gradient will be different?




Aucun commentaire:

Enregistrer un commentaire