Source

style/generateProgressiveColors.js

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Generate array of colors like rainbow.
 * Useful to generate colors from warm color to cool color.
 * If difference between endHue and startHue greater than 360,
 * it is possible to got duplicated colors
 * @param numberOfColors
 * @param options
 * @returns array of HSL color code
 * @category style
 * @module generateProgressiveColors
 */
var generateProgressiveColors = function (numberOfColors, options) {
    if (options === void 0) { options = {}; }
    var _a = options.startHue, startHue = _a === void 0 ? 0 : _a, _b = options.endHue, endHue = _b === void 0 ? 300 : _b, _c = options.saturation, saturation = _c === void 0 ? 100 : _c, _d = options.lightness, lightness = _d === void 0 ? 50 : _d;
    var hueDiff = numberOfColors > 1 ? (endHue - startHue) / (numberOfColors - 1) : 0;
    return new Array(numberOfColors).fill('')
        .map(function (d, index) { return ("hsl(".concat(startHue + (hueDiff * index), ", ").concat(saturation, "%, ").concat(lightness, "%)")); });
};
exports.default = generateProgressiveColors;