Random
Following are the Random functions in Chelsea.js
All the functions are briefly explained in easy-to-understand language.
Random
The random function returns a random number in the given range.
random(min, max);
random(4, 10); // returns a random number between 4 and 10
Random Integer
The randomInt function returns a random integer in the given range.
randomInt(min, max);
randomInt(3,14); // returns a random integer between 3 and 14
Random Boolean
The randomBool function returns a random boolean value.(True or False)
randomBool(); // returns a random boolean value
Random Element
The randomElement function returns a random element from the given array.
randomElement(array);
randomElement(['a', 'b', 'c']); // returns a random element from the given array i.e. 'a' or 'b' or 'c'
Random Color RGB
The randomColorRGB function returns a random color in RGB format.
randomColorRGB(); // returns a random color in RGB format, for example rgb(23,65,145)
Random Color RGBA
The randomColorRGBA function returns a random color in RGBA format.
randomColorRGBA(); // returns a random color in RGBA format, for example rgba(213,65,145,0.5)
Random Color HSL
The randomColorHSL function returns a random color in HSL format.
randomColorHSL(); // returns a random color in HSL format, for example hsl(213,65%,35%)
Random Color HSLA
The randomColorHSLA function returns a random color in HSLA format.
randomColorHSLA(); // returns a random color in HSLA format, for example hsla(213,65%,35%,0.5)
Random Color Hex
The randomColorHex function returns a random color in Hex format.
randomColorHex(); // returns a random color in Hex format, for example #ff00ff
Random Gaussian
The randomGaussian function returns a random number with a Gaussian or Normal distribution.
It means, that the the random number is more probable to be near the mean value.
I like to call it a "Biased Random Number" because it is biased towards the mean value.
randomGaussian(mean, standardDeviation);
randomGaussian(0, 1); // returns a random number with a Gaussian or Normal distribution
Random Vector
randomVector() generates a normalized random vector.
randomVector();
Random Vector with Components
randomVectorComp(min, max) generates a vector with random components between minimum and maximum value.
randomVectorComp(min, max);
Random Vector with Magnitude
randomVectorMagnitude(min, max) generates a random vector with the specified minimum and maximum values.
randomVectorMagnitude(min, max);
Random Vector with Angle
randomVectorAngle(angle, min, max) generates a random vector with magnitude between m1, m2 at a given angle.
magnitude constraints are optional.
randomVectorAngle(angle, min, max);