fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Client / Color

Class: Color

Represents a color with red, green, blue, and alpha (opacity) components.

Constructors

new Color()

new Color(r, g, b, a): Color

Creates a new Color instance.

Parameters

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).

Returns

Color

Defined in

client/utils/Color.ts:154

Properties

a

a: number = 255

The alpha (opacity) component of the color (0-255).

Defined in

client/utils/Color.ts:158


b

b: number

The blue component of the color (0-255).

Defined in

client/utils/Color.ts:157


g

g: number

The green component of the color (0-255).

Defined in

client/utils/Color.ts:156


r

r: number

The red component of the color (0-255).

Defined in

client/utils/Color.ts:155


aqua

static aqua: Color

The color aqua (RGB: 0, 255, 255).

Defined in

client/utils/Color.ts:100


black

static black: Color

The color black (RGB: 0, 0, 0).

Defined in

client/utils/Color.ts:20


blue

static blue: Color

The color blue (RGB: 0, 0, 255).

Defined in

client/utils/Color.ts:90


brown

static brown: Color

The color brown (RGB: 165, 42, 42).

Defined in

client/utils/Color.ts:115


chocolate

static chocolate: Color

The color chocolate (RGB: 210, 105, 30).

Defined in

client/utils/Color.ts:145


coral

static coral: Color

The color coral (RGB: 255, 127, 80).

Defined in

client/utils/Color.ts:125


empty

static empty: Color

A transparent color (fully transparent).

Defined in

client/utils/Color.ts:10


fuchsia

static fuchsia: Color

The color fuchsia (RGB: 255, 0, 255).

Defined in

client/utils/Color.ts:60


gold

static gold: Color

The color gold (RGB: 255, 215, 0).

Defined in

client/utils/Color.ts:130


gray

static gray: Color

The color gray (RGB: 128, 128, 128).

Defined in

client/utils/Color.ts:35


green

static green: Color

The color green (RGB: 0, 128, 0).

Defined in

client/utils/Color.ts:65


khaki

static khaki: Color

The color khaki (RGB: 240, 230, 140).

Defined in

client/utils/Color.ts:135


lightCoral

static lightCoral: Color

The color light coral (RGB: 240, 128, 128).

Defined in

client/utils/Color.ts:120


lime

static lime: Color

The color lime (RGB: 0, 255, 0).

Defined in

client/utils/Color.ts:70


maroon

static maroon: Color

The color maroon (RGB: 128, 0, 0).

Defined in

client/utils/Color.ts:45


static navy: Color

The color navy (RGB: 0, 0, 128).

Defined in

client/utils/Color.ts:85


olive

static olive: Color

The color olive (RGB: 128, 128, 0).

Defined in

client/utils/Color.ts:75


orange

static orange: Color

The color orange (RGB: 255, 165, 0).

Defined in

client/utils/Color.ts:105


pink

static pink: Color

The color pink (RGB: 255, 192, 203).

Defined in

client/utils/Color.ts:110


purple

static purple: Color

The color purple (RGB: 128, 0, 128).

Defined in

client/utils/Color.ts:55


red

static red: Color

The color red (RGB: 255, 0, 0).

Defined in

client/utils/Color.ts:50


salmon

static salmon: Color

The color salmon (RGB: 250, 128, 114).

Defined in

client/utils/Color.ts:140


silver

static silver: Color

The color silver (RGB: 192, 192, 192).

Defined in

client/utils/Color.ts:40


teal

static teal: Color

The color teal (RGB: 0, 128, 128).

Defined in

client/utils/Color.ts:95


transparent

static transparent: Color

A fully transparent color.

Defined in

client/utils/Color.ts:15


white

static white: Color

The color white (RGB: 255, 255, 255).

Defined in

client/utils/Color.ts:25


whiteSmoke

static whiteSmoke: Color

The color white smoke (RGB: 245, 245, 245).

Defined in

client/utils/Color.ts:30


yellow

static yellow: Color

The color yellow (RGB: 255, 255, 0).

Defined in

client/utils/Color.ts:80

Methods

adjustBrightness()

adjustBrightness(factor): Color

Adjusts the brightness of the color.

Parameters

factor: number

The factor by which to adjust the brightness. Values less than 1 darken the color, values greater than 1 lighten the color.

Returns

Color

A new Color instance with adjusted brightness.

Defined in

client/utils/Color.ts:266


blend()

blend(other, ratio): Color

Blends this color with another color.

Parameters

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.

Returns

Color

A new Color instance representing the blended color.

Defined in

client/utils/Color.ts:299


darken()

darken(percentage): Color

Darkens the color by a percentage.

Parameters

percentage: number

The percentage by which to darken the color.

Returns

Color

A new Color instance that is darker by the specified percentage.

Defined in

client/utils/Color.ts:280


equals()

equals(other): boolean

Checks if this color is equal to another color.

Parameters

other: Color

The color to compare with.

Returns

boolean

true if the colors are equal, false otherwise.

Defined in

client/utils/Color.ts:166


invert()

invert(): Color

Inverts the color.

Returns

Color

A new Color instance representing the inverted color.

Defined in

client/utils/Color.ts:314


lighten()

lighten(percentage): Color

Lightens the color by a percentage.

Parameters

percentage: number

The percentage by which to lighten the color.

Returns

Color

A new Color instance that is lighter by the specified percentage.

Defined in

client/utils/Color.ts:289


toArgbHex()

toArgbHex(): string

Converts the color to a hexadecimal string (ARGB format).

Returns

string

A string in the format #aarrggbb.

Defined in

client/utils/Color.ts:211


toArray()

toArray(): [number, number, number, number]

Converts the color to an array.

Returns

[number, number, number, number]

An array representing the color with [r, g, b, a] components.

Defined in

client/utils/Color.ts:187


toHex()

toHex(): string

Converts the color to a hexadecimal string (RGB format).

Returns

string

A string in the format #rrggbb.

Defined in

client/utils/Color.ts:203


toHsl()

toHsl(): object

Converts the color to HSL format.

Returns

object

An object with h (hue), s (saturation), l (lightness), and a (alpha) properties.

a

a: number

h

h: number

l

l: number

s

s: number

Defined in

client/utils/Color.ts:219


toJson()

toJson(): object

Converts the color to a JSON object.

Returns

object

An object representing the color with r, g, b, and a properties.

a

a: number

b

b: number

g

g: number

r

r: number

Defined in

client/utils/Color.ts:174


toRgbaString()

toRgbaString(): string

Converts the color to an RGBA string.

Returns

string

A string in the format rgba(r, g, b, a).

Defined in

client/utils/Color.ts:195


fromArgb()

static fromArgb(a, r, g, b): Color

Creates a new Color instance from ARGB values.

Parameters

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).

Returns

Color

A new Color instance.

Defined in

client/utils/Color.ts:336


fromHex()

static fromHex(hex): Color

Creates a new Color instance from a hexadecimal color string.

Parameters

hex: string

The hexadecimal color string (e.g., #RRGGBB).

Returns

Color

A new Color instance.

Defined in

client/utils/Color.ts:356


fromHsl()

static fromHsl(h, s, l, a): Color

Creates a new Color instance from HSL values.

Parameters

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).

Returns

Color

A new Color instance.

Defined in

client/utils/Color.ts:399


fromRgb()

static fromRgb(r, g, b): Color

Creates a new Color instance from RGB values.

Parameters

r: number

The red component (0-255).

g: number

The green component (0-255).

b: number

The blue component (0-255).

Returns

Color

A new Color instance with full opacity (alpha = 255).

Defined in

client/utils/Color.ts:347


fromRgbaString()

static fromRgbaString(rgba): Color

Creates a new Color instance from an RGBA string.

Parameters

rgba: string

The RGBA color string (e.g., rgba(255, 0, 0, 1)).

Returns

Color

A new Color instance.

Throws

Error if the RGBA string is invalid.

Defined in

client/utils/Color.ts:375