-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
RandomRGB.js
30 lines (26 loc) · 935 Bytes
/
RandomRGB.js
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
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Between = require('../../math/Between');
var Color = require('./Color');
/**
* Creates a new Color object where the r, g, and b values have been set to random values
* based on the given min max values.
*
* @function Phaser.Display.Color.RandomRGB
* @since 3.0.0
*
* @param {number} [min=0] - The minimum value to set the random range from (between 0 and 255)
* @param {number} [max=255] - The maximum value to set the random range from (between 0 and 255)
*
* @return {Phaser.Display.Color} A Color object.
*/
var RandomRGB = function (min, max)
{
if (min === undefined) { min = 0; }
if (max === undefined) { max = 255; }
return new Color(Between(min, max), Between(min, max), Between(min, max));
};
module.exports = RandomRGB;