a library to speed up the development of Fivem scripts and frameworks
fivem-ts - Documentation v0.7.5 • Docs
fivem-ts - Documentation v0.7.5 / Client / Color
Represents a color with red, green, blue, and alpha (opacity) components.
new Color(
r
,g
,b
,a
):Color
Creates a new Color
instance.
• r: number
The red component of the color (0-255).
• g: number
The green component of the color (0-255).
• b: number
The blue component of the color (0-255).
• a: number
= 255
The alpha (opacity) component of the color (0-255).
a:
number
=255
The alpha (opacity) component of the color (0-255).
b:
number
The blue component of the color (0-255).
g:
number
The green component of the color (0-255).
r:
number
The red component of the color (0-255).
static
aqua:Color
The color aqua (RGB: 0, 255, 255).
static
black:Color
The color black (RGB: 0, 0, 0).
static
blue:Color
The color blue (RGB: 0, 0, 255).
static
brown:Color
The color brown (RGB: 165, 42, 42).
static
chocolate:Color
The color chocolate (RGB: 210, 105, 30).
static
coral:Color
The color coral (RGB: 255, 127, 80).
static
empty:Color
A transparent color (fully transparent).
static
fuchsia:Color
The color fuchsia (RGB: 255, 0, 255).
static
gold:Color
The color gold (RGB: 255, 215, 0).
static
gray:Color
The color gray (RGB: 128, 128, 128).
static
green:Color
The color green (RGB: 0, 128, 0).
static
khaki:Color
The color khaki (RGB: 240, 230, 140).
static
lightCoral:Color
The color light coral (RGB: 240, 128, 128).
static
lime:Color
The color lime (RGB: 0, 255, 0).
static
maroon:Color
The color maroon (RGB: 128, 0, 0).
static
navy:Color
The color navy (RGB: 0, 0, 128).
static
olive:Color
The color olive (RGB: 128, 128, 0).
static
orange:Color
The color orange (RGB: 255, 165, 0).
static
pink:Color
The color pink (RGB: 255, 192, 203).
static
purple:Color
The color purple (RGB: 128, 0, 128).
static
red:Color
The color red (RGB: 255, 0, 0).
static
salmon:Color
The color salmon (RGB: 250, 128, 114).
static
silver:Color
The color silver (RGB: 192, 192, 192).
static
teal:Color
The color teal (RGB: 0, 128, 128).
static
transparent:Color
A fully transparent color.
static
white:Color
The color white (RGB: 255, 255, 255).
static
whiteSmoke:Color
The color white smoke (RGB: 245, 245, 245).
static
yellow:Color
The color yellow (RGB: 255, 255, 0).
adjustBrightness(
factor
):Color
Adjusts the brightness of the color.
• factor: number
The factor by which to adjust the brightness. Values less than 1 darken the color, values greater than 1 lighten the color.
A new Color
instance with adjusted brightness.
blend(
other
,ratio
):Color
Blends this color with another color.
• other: Color
The color to blend with.
• ratio: number
The ratio of blending between this color and the other color. 0
means full color, 1
means full other
color.
A new Color
instance representing the blended color.
darken(
percentage
):Color
Darkens the color by a percentage.
• percentage: number
The percentage by which to darken the color.
A new Color
instance that is darker by the specified percentage.
equals(
other
):boolean
Checks if this color is equal to another color.
• other: Color
The color to compare with.
boolean
true
if the colors are equal, false
otherwise.
invert():
Color
Inverts the color.
A new Color
instance representing the inverted color.
lighten(
percentage
):Color
Lightens the color by a percentage.
• percentage: number
The percentage by which to lighten the color.
A new Color
instance that is lighter by the specified percentage.
toArgbHex():
string
Converts the color to a hexadecimal string (ARGB format).
string
A string in the format #aarrggbb
.
toArray(): [
number
,number
,number
,number
]
Converts the color to an array.
[number
, number
, number
, number
]
An array representing the color with [r, g, b, a]
components.
toHex():
string
Converts the color to a hexadecimal string (RGB format).
string
A string in the format #rrggbb
.
toHsl():
object
Converts the color to HSL format.
object
An object with h
(hue), s
(saturation), l
(lightness), and a
(alpha) properties.
a:
number
h:
number
l:
number
s:
number
toJson():
object
Converts the color to a JSON object.
object
An object representing the color with r
, g
, b
, and a
properties.
a:
number
b:
number
g:
number
r:
number
toRgbaString():
string
Converts the color to an RGBA string.
string
A string in the format rgba(r, g, b, a)
.
static
fromArgb(a
,r
,g
,b
):Color
Creates a new Color
instance from ARGB values.
• a: number
The alpha (opacity) component (0-255).
• r: number
The red component (0-255).
• g: number
The green component (0-255).
• b: number
The blue component (0-255).
A new Color
instance.
static
fromHex(hex
):Color
Creates a new Color
instance from a hexadecimal color string.
• hex: string
The hexadecimal color string (e.g., #RRGGBB
).
A new Color
instance.
static
fromHsl(h
,s
,l
,a
):Color
Creates a new Color
instance from HSL values.
• h: number
The hue (0-360 degrees).
• s: number
The saturation (0-100).
• l: number
The lightness (0-100).
• a: number
= 255
The alpha (opacity) component (0-255).
A new Color
instance.
static
fromRgb(r
,g
,b
):Color
Creates a new Color
instance from RGB values.
• r: number
The red component (0-255).
• g: number
The green component (0-255).
• b: number
The blue component (0-255).
A new Color
instance with full opacity (alpha = 255).
static
fromRgbaString(rgba
):Color
Creates a new Color
instance from an RGBA string.
• rgba: string
The RGBA color string (e.g., rgba(255, 0, 0, 1)
).
A new Color
instance.
Error if the RGBA string is invalid.