Constructor
new Color(rac, r, g, b, aopt)
Creates a new Color
instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
||
r |
number
|
The red channel value, in the [0,1] range |
||
g |
number
|
The green channel value, in the [0,1] range |
||
b |
number
|
The blue channel value, in the [0,1] range |
||
a |
number
|
<optional> |
1 |
The alpha channel value, in the [0,1] range |
Members
rac :Rac
Instance of Rac
used for drawing and passed along to any created
object.
Methods
(static) fromHex(rac, hexString) → {Rac.Color}
Creates a new Color
instance from a hexadecimal triplet string.
The hexString
is expected to have 6 digits and can optionally start
with #
. AABBCC
and #DDEEFF
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 |
---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
hexString |
string
|
The RGB hex triplet to interpret |
(static) fromRgba(rac, r, g, b, aopt) → {Rac.Color}
Creates a new Color
instance with each channel received in the
[0,255] range
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
||
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 |
fill() → {Rac.Fill}
Returns a new Fill
that uses this
as color
.
linearTransition(ratio, target) → {Rac.Color}
Returns a new Color
in the linear transition between this
and
target
at a ratio
in the range [0,1].
When ratio
is 0
or less the new Color
is equivalent to this
,
when ratio
is 1
or larger the new Color
is equivalent to
target
.
Parameters:
Name | Type | Description |
---|---|---|
ratio |
number
|
The transition ratio for the new |
target |
Rac.Color
|
The transition target |
stroke(weightnullable) → {Rac.Stroke}
Returns a new Stroke
that uses this
as color
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
weight |
number
|
<nullable> |
null |
The weight of the new |
toString() → {string}
Returns a string representation intended for human consumption.
withAlpha(newAlpha) → {Rac.Color}
Returns a new Color
with a
set to newAlpha
.
Parameters:
Name | Type | Description |
---|---|---|
newAlpha |
number
|
The alpha channel for the new |
withAlphaRatio(ratio) → {Rac.Color}
Returns a new Color
with a
set to this.a * ratio
.
Parameters:
Name | Type | Description |
---|---|---|
ratio |
number
|
The factor to multiply |