This function will normalize RGB or RGBA colors from string to integers for Jimp to use.
More on the Jimp GitHub Page
However if already a number is passed, it will be returned as is.
Furthermore a string will be tested against a regex, which will test if the string contains numbers.
If the alpha channel is not provided, it will be added as 255 on the last position of the array (string is split).
If the color is not a number or a string, it will be returned.
// this is the initial rgb value. constrgb: string = '180, -20, 30';
// will be transformed to colorchannels like so: consttransformedRGBArr: string[] = [ '180', '20', '30', '255' ]
// after that it will be clamped into a integer value like this: constrgbIntVal: number = 3021217535;
Look into the function to understand it deeper.
@param {string} color a string or number representing RGB or RGBA values: '180, -20, 30' or 3021217535 (both are the same)
@return {number} Will return a integer value representing a given RGB or RGBA string value.
This function will normalize RGB or RGBA colors from string to integers for Jimp to use. More on the Jimp GitHub Page
However if already a number is passed, it will be returned as is. Furthermore a string will be tested against a regex, which will test if the string contains numbers. If the alpha channel is not provided, it will be added as 255 on the last position of the array (string is split). If the color is not a number or a string, it will be returned.
Look into the function to understand it deeper. @param {string} color a string or number representing RGB or RGBA values: '180, -20, 30' or 3021217535 (both are the same)
@return {number} Will return a integer value representing a given RGB or RGBA string value.