Color object (red, green, blue, alpha) with some helpful functions
Create a color with the rgba components passed in, white by default
r number optional, default 1red
g number optional, default 1green
b number optional, default 1blue
a number optional, default 1alpha
let a = new Color; // white
let b = new Color(1, 0, 0); // red
let c = new Color(0, 0, 0, 0); // transparent black
let d = rgb(0, 0, 1); // blue using rgb color
let e = hsl(.3, 1, .5); // green using hsl color
Returns a copy of this color plus the color passed in
c Colorother color
Returns a copy of this color clamped to the valid range between 0 and 1
Returns a new color that is a copy of this
Returns a copy of this color divided by the color passed in
c Colorother color
Returns this color expressed in hsla format
Checks if this is a valid color
Returns a new color that is p percent between this and the color passed in, percent is clamped to 0-1
c Colorother color
percent number
Returns a copy of this color times the color passed in
c Colorother color
Returns a new color that has each component randomly adjusted
amount number optional, default 0.05alphaAmount number optional, default 0
Returns this color expressed as 32 bit RGBA value
Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
scale numberalphaScale number optional, default scale
Sets values of this color and returns self
r number optional, default 1red
g number optional, default 1green
b number optional, default 1blue
a number optional, default 1alpha
Sets the alpha of this color and returns self
a number optional, default 1alpha
Sets this color from another color and returns self
c Colorother color
Set this color from a hex code
hex stringhtml hex code
Sets this color given a hue, saturation, lightness, and alpha
h number optional, default 0hue
s number optional, default 0saturation
l number optional, default 1lightness
a number optional, default 1alpha
Returns a copy of this color minus the color passed in
c Colorother color
Returns this color expressed as a hex color code
useAlpha boolean optional, default trueif alpha should be included in result
Returns a copy of this color with the alpha set
a number optional, default 1alpha