ReadonlyaAlpha/transparent component. . 0 = transparent
ReadonlybBlue component.
ReadonlygGreen component.
ReadonlyrRed component. Should be in the range [0, 1].
StaticblackStaticblueStaticclayStaticgrayStaticgreenStaticorangeStaticpurpleStaticredStatictransparentStaticwhiteStaticyellowConverts 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.
StaticaverageStaticcontrastReturns the contrast ratio
between colorA and colorB.
StaticfromCreates a Color4 from a three or four-component hexadecimal
color string.
Example:
import { Color4 } from '@js-draw/math';
console.log(Color4.fromHex('#ff0'));
StaticfromHSVCreates 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.
StaticfromRGBArrayCreates 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.
StaticfromRGBVectorStaticfromStaticofRGBStaticofRGBA
Represents a color.
Example
import { Color4 } from '@js-draw/math'; console.log('Red:', Color4.fromString('#f00')); console.log('Also red:', Color4.ofRGB(1, 0, 0), Color4.red); console.log('Mixing red and blue:', Color4.red.mix(Color4.blue, 0.5)); console.log('To string:', Color4.orange.toHexString());