Readonly
aAlpha/transparent component. . 0 = transparent
Readonly
bBlue component.
Readonly
gGreen component.
Readonly
rRed component. Should be in the range [0, 1].
Static
blackStatic
blueStatic
clayStatic
grayStatic
greenStatic
orangeStatic
purpleStatic
redStatic
transparentStatic
whiteStatic
yellowConverts to (hue, saturation, value). See also https://en.wikipedia.org/wiki/HSL_and_HSV#General_approach
The resultant hue is represented in radians and is thus in .
If fractionTo
is not in the range , it will be clamped to the nearest number
in that range. For example, a.mix(b, -1)
is equivalent to a.mix(b, 0)
.
a color fractionTo
of the way from this color to other
.
Returns the relative luminance of this color in the sRGB color space.
Ignores the alpha component.
Static
averageStatic
contrastReturns the contrast ratio
between colorA
and colorB
.
Static
fromCreates a Color4
from a three or four-component hexadecimal
color string.
Example:
import { Color4 } from '@js-draw/math'; console.log(Color4.fromHex('#ff0'));
Static
fromHSVCreates a new Color4
from a representation in .
Note that hue must be given in radians. While non-standard, this is consistent with asHSV.
hue
and value
should range from 0 to 1.
Static
fromRGBArrayCreates a color from an RGB (or RGBA) array.
This is similar to ofRGB and ofRGBA, but, by default, takes values that range from 0 to 255.
If the array values instead range from 0-1, pass maxValue
as 1
.
Static
fromRGBVectorStatic
fromStatic
ofRGBStatic
ofRGBA
Represents a color.
Example