Set of JavaScript classes were created for color manipulations. With these classes you can change color components independently. Original transformation algorithm between HSL <> RGB and HSB <> RGB you can grab here.
via npm
npm install gist:bca61f39fc4819768eb55a7c812f7e52 --save
via git
git clone https://gist.github.com/burdiuz/bca61f39fc4819768eb55a7c812f7e52 Pixels
- new RGBA(color:uint) - Class constructor accepts RGBA color value
- get/set r:byte - red component of RGBA color value. Accepts values between 0 and 255.
- get/set g:byte - green component of RGBA color value. Accepts values between 0 and 255.
- get/set b:byte - blue component of RGBA color value. Accepts values between 0 and 255.
- get/set a:byte - alpha/opacity component of RGBA color value. Accepts values between 0 and 255.
- get/set value:uint - get/set RGBA color value.
- static getRed(color:uint):byte - get red component from RGBA color value.
- static getGreen(color:uint):byte - get green component from RGBA color value.
- static getBlue(color:uint):byte - get blue component from RGBA color value.
- static getAlpha(color:uint):byte - get alpha/opacity component from RGBA color value.
- static setRed(color:uint, red:byte):uint - set red component value to RGBA color.
- static setGreen(color:uint, green:byte):uint - set green component value to RGBA color.
- static setBlue(color:uint, blue:byte):uint - set blue component value to RGBA color.
- static setAlpha(color:uint, alpha:byte):uint - set alpha/opacity component value to RGBA color.
- new HSLA(color:uint) - Class constructor accepts RGBA color value.
- get/set h:float - hue component of RGBA color value. Accepts values between 0 and 1.
- get/set s:float - saturation component of RGBA color value. Accepts values between 0 and 1.
- get/set l:float - light component of RGBA color value. Accepts values between 0 and 1.
- get/set a:float - alpha/opacity component of RGBA color value. Accepts values between 0 and 1.
- get/set value:uint - get/set RGBA color value.
- static toRGBA(h:float, s:float, l:float, a:float = 1):uint - Combine hue, saturation, light and opacity to transform into RGBA color value.
- new HSBA(color:uint) - Class constructor accepts RGBA color value.
- get/set h:float - hue component of RGBA color value. Accepts values between 0 and 1.
- get/set s:float - saturation component of HSBA color value. Accepts values between 0 and 1.
- get/set b:float - brightness component of RGBA color value. Accepts values between 0 and 1.
- get/set a:float - alpha/opacity component of RGBA color value. Accepts values between 0 and 1.
- get/set value:uint - get/set RGBA color value.
- static toRGBA(h:float, s:float, b:float, a:float = 1):uint - Combine hue, saturation, brightness and opacity to transform into RGBA color value.