'use strict';
const Rac = require('../Rac');
/**
* The `instance.Color` function contains convenience methods and members
* for `{@link Rac.Color}` objects setup with the owning `Rac` instance.
*
* @namespace instance.Color
*/
module.exports = function attachRacColor(rac) {
// Intended to receive a Rac instance as parameter
/**
* Returns a new `Color` with each channel received in the *[0,255]* range.
*
* @param {number} r - The red channel value, in the *[0,255]* range
* @param {number} g - The green channel value, in the *[0,255]* range
* @param {number} b - The blue channel value, in the *[0,255]* range
* @param {number} [a=255] - The alpha channel value, in the *[0,255]* range
*
* @returns {Rac.Color}
*
* @function fromRgba
* @memberof instance.Color#
*/
rac.Color.fromRgba = function(r, g, b, a = 255) {
return Rac.Color.fromRgba(rac, r, g, b, a);
};
/**
* Returns a new `Color` instance from a hexadecimal triplet string.
*
* The `hexString` is expected to have 6 digits and can optionally start
* with `#`. `AABBCC` and `#DDEEFF` are both valid inputs, the three digit
* shorthand is not yet supported.
*
* An error is thrown if `hexString` is misformatted or cannot be parsed.
*
* @param {string} hexString - The RGB hex triplet to interpret
* @returns {Rac.Color}
*/
rac.Color.fromHex = function(hexString) {
return Rac.Color.fromHex(rac, hexString);
}
/**
* A black `Color`.
*
* @name black
* @memberof instance.Color#
*/
rac.Color.black = rac.Color(0, 0, 0);
/**
* A red `Color`.
*
* @name red
* @memberof instance.Color#
*/
rac.Color.red = rac.Color(1, 0, 0);
rac.Color.green = rac.Color(0, 1, 0);
rac.Color.blue = rac.Color(0, 0, 1);
rac.Color.yellow = rac.Color(1, 1, 0);
rac.Color.magenta = rac.Color(1, 0, 1);
rac.Color.cyan = rac.Color(0, 1, 1);
rac.Color.white = rac.Color(1, 1, 1);
} // attachRacColor