Implement a color. All color components are expected to be in 0.0 - 1.0 range (and not 0-255).
Convert Hex value to Color instance.
Implement a color. All color components are expected to be in 0.0 - 1.0 range (and not 0-255).
Kind: global class
Number
Number
Number
Number
Number
Number
Number
Number
String
Number
Number
Color
Color
Color
\*
Number
Array.<String>
String
Color
Color
Color
Color
Color
Color
Create the color.
Param | Type | Description |
---|---|---|
r | Number |
Color red component (value range: 0-1). |
g | Number |
Color green component (value range: 0-1). |
b | Number |
Color blue component (value range: 0-1). |
[a] | Number |
Color alpha component (value range: 0-1). |
Number
Get r component.
Kind: instance property of Color
Returns: Number
- Red component.
Number
Get g component.
Kind: instance property of Color
Returns: Number
- Green component.
Number
Get b component.
Kind: instance property of Color
Returns: Number
- Blue component.
Number
Get a component.
Kind: instance property of Color
Returns: Number
- Alpha component.
Number
Set r component.
Kind: instance property of Color
Returns: Number
- Red component after change.
Number
Set g component.
Kind: instance property of Color
Returns: Number
- Green component after change.
Number
Set b component.
Kind: instance property of Color
Returns: Number
- Blue component after change.
Number
Set a component.
Kind: instance property of Color
Returns: Number
- Alpha component after change.
String
Convert this color to hex string (starting with ‘#’).
Kind: instance property of Color
Returns: String
- Color as hex.
Number
Convert this color to decimal number.
Kind: instance property of Color
Returns: Number
- Color as decimal RGBA.
Number
Convert this color to decimal number.
Kind: instance property of Color
Returns: Number
- Color as decimal ARGB.
Convert this color to a float array.
Kind: instance property of Color
Get if this color is pure black (ignoring alpha).
Kind: instance property of Color
Get if this color is transparent black.
Kind: instance property of Color
Color
Set the color components.
Kind: instance method of Color
Returns: Color
- this.
Param | Type | Description |
---|---|---|
r | Number |
Color red component (value range: 0-1). |
g | Number |
Color green component (value range: 0-1). |
b | Number |
Color blue component (value range: 0-1). |
a | Number |
Color alpha component (value range: 0-1). |
Color
Set the color components from byte values (0-255).
Kind: instance method of Color
Returns: Color
- this.
Param | Type | Description |
---|---|---|
r | Number |
Color red component (value range: 0-255). |
g | Number |
Color green component (value range: 0-255). |
b | Number |
Color blue component (value range: 0-255). |
a | Number |
Color alpha component (value range: 0-255). |
Color
Copy all component values from another color.
Kind: instance method of Color
Returns: Color
- this.
Param | Type | Description |
---|---|---|
other | Color |
Color to copy values from. |
\*
Convert to dictionary.
Kind: instance method of Color
Returns: \*
- Dictionary with {r,g,b,a}
Param | Type | Description |
---|---|---|
minimized | Boolean |
If true, will not include keys that their values are 1. You can use fromDict on minimized dicts. |
Number
Return a clone of this color.
Kind: instance method of Color
Returns: Number
- Cloned color.
Convert to string.
Kind: instance method of Color
Check if equal to another color.
Kind: instance method of Color
Param | Type | Description |
---|---|---|
other | Color |
Other color to compare to. |
Array.<String>
Get array with all built-in web color names.
Kind: static property of Color
Returns: Array.<String>
- Array with color names.
String
Convert a single component to hex value.
Kind: static method of Color
Returns: String
- Component as hex value.
Param | Type | Description |
---|---|---|
c | Number |
Value to convert to hex. |
Color
Create color from hex value.
Kind: static method of Color
Returns: Color
- New color value.
Param | Type | Description |
---|---|---|
val | String |
Number value (hex), as #rrggbbaa. |
Color
Create color from decimal value.
Kind: static method of Color
Returns: Color
- New color value.
Param | Type | Description |
---|---|---|
val | Number |
Number value (int). |
includeAlpha | Number |
If true, will include alpha value. |
Color
Create color from a dictionary.
Kind: static method of Color
Returns: Color
- Newly created color.
Param | Type | Description |
---|---|---|
data | \* |
Dictionary with {r,g,b,a}. |
Color
Return a random color.
Kind: static method of Color
Returns: Color
- Randomized color.
Param | Type | Description |
---|---|---|
includeAlpha | Boolean |
If true, will also randomize alpha. |
Color
Build and return new color from bytes array.
Kind: static method of Color
Returns: Color
- Newly created color.
Param | Type | Description |
---|---|---|
bytes | Array.<Number> |
Bytes array to build color from. |
[offset] | Number |
Optional offset to read bytes from. |
Color
Lerp between two colors.
Kind: static method of Color
Returns: Color
- result color.
Param | Type | Description |
---|---|---|
p1 | Color |
First color. |
p2 | Color |
Second color. |
a | Number |
Lerp factor (0.0 - 1.0). |
Convert Hex value to Color instance.
Kind: global function
Param | Type | Description |
---|---|---|
hex | String |
Hex value to parse. |