Class: RgbColor
Represents a color with red, green and blue components.
Extended by
Implements
Cloneable<RgbColor>
Constructors
Constructor
new RgbColor(
colorString):RgbColor
Creates a new RgbColor instance from a string representation (hex, rgb or hsl).
Parameters
colorString
string
The string representation of the color.
Returns
RgbColor
Throws
If the input string is not a valid color representation.
Constructor
new RgbColor(
r?,g?,b?):RgbColor
Creates a new RgbColor instance.
Parameters
r?
number
The red component of the color (0 to 255).
g?
number
The green component of the color (0 to 255).
b?
number
The blue component of the color (0 to 255).
Returns
RgbColor
Properties
b
b:
number
The blue component of the color (0 to 255).
g
g:
number
The green component of the color (0 to 255).
r
r:
number
The red component of the color (0 to 255).
Accessors
blue
Get Signature
get blue():
number
The intensity of blue in the described color as a value 0-255.
Returns
number
green
Get Signature
get green():
number
The intensity of green in the described color as a value 0-255.
Returns
number
red
Get Signature
get red():
number
The intensity of red in the described color as a value 0-255.
Returns
number
Methods
clone()
clone():
RgbColor
Creates a deep copy of the object.
Returns
RgbColor
A new instance that is a deep copy of the original object.
Implementation of
setRGB()
setRGB(
red,green,blue):void
Set a new color with all components at once
Parameters
red
number
green
number
blue
number
Returns
void
toHexString()
toHexString():
string
Converts the color to a hexadecimal string
Returns
string
A string representation of the color in hexadecimal
Example
#330000
toRgbaString()
toRgbaString():
string
Converts the color to a CSS-formatted RGBA string.
Returns
string
A string representation of the color in RGBA format.
toRgbString()
toRgbString():
string
Converts the color to a CSS-formatted RGB string.
Returns
string
A string representation of the color in RGB format.