'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var defaults = require('./defaults');
var random = require('./random');
var Color = require('./Color');
var seedRandom = require('./seedRandom');
var isFn = require('./isFn');
exports = function() {
    var options =
        arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    defaults(options, defOpts);
    var count = options.count;
    var randomH = options.randomH,
        randomL = options.randomL,
        randomS = options.randomS;
    if (!isFn(randomH)) {
        var seed = options.seed || random(0, 100000);
        randomH = seedRandom(seed, 0, 360, false);
        randomL = seedRandom(seed + 1, 0, 1);
        randomS = seedRandom(seed + 2, 0, 1);
    }
    if (count > 1) {
        var colors = [];
        for (var i = 0; i < count; i++) {
            colors.push(
                exports(
                    defaults(
                        {
                            count: 1,
                            randomH: randomH,
                            randomL: randomL,
                            randomS: randomS
                        },
                        options
                    )
                )
            );
        }
        return colors;
    }
    var hue = options.hue || randomH();
    var lightness = options.lightness || randomL().toFixed(2);
    var saturation = options.saturation || randomS().toFixed(2);
    var color = new Color({
        val: [hue, Math.round(saturation * 100), Math.round(lightness * 100)],
        model: 'hsl'
    });
    switch (options.format) {
        case 'hsl':
            return color.toHsl();
        case 'rgb':
            return color.toRgb();
        default:
            return color.toHex();
    }
};
var defOpts = {
    count: 1,
    format: 'hex'
};
 
module.exports = exports;