Members and methods attached to the
rac.Color
function.
The function contains ready-made convenience
Color
objects for usual values, all setup with the
owning Rac
instance.
Example
let rac = new Rac()
rac.Color.red // ready-made red color
rac.Color.red.rac === rac // true
Members
white
A white Color
, with all channels set to 1
.
Also available as one
.
Methods
fromHex(hexString) → {Rac.Color}
Returns a new Color
instance from a hexadecimal triplet or quadruplet
string.
The hexString
is expected to have 6 or 8 hex digits for the RGB and
optionally alpha channels. It can start with #
. AABBCC
and
#CCDDEEFF
are both valid inputs.
The three digit shorthand is not yet supported.
An error is thrown if hexString
is misformatted or cannot be parsed.
Parameters:
Name | Type | Description |
---|---|---|
hexString |
String
|
The hex string to interpret |
fromRgba(r, g, b, aopt) → {Rac.Color}
Returns a new Color
with each channel received in the [0,255] range.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
r |
Number
|
The red channel value, in the [0,255] range |
||
g |
Number
|
The green channel value, in the [0,255] range |
||
b |
Number
|
The blue channel value, in the [0,255] range |
||
a |
Number
|
<optional> |
255
|
The alpha channel value, in the [0,255] range |