Lua API
  • 🔎Overview
  • Introduction
    • 🚀Creating scripts
      • 🧠First Steps
      • 🖥️Adding UI
      • 📚Creating Libraries
  • API
    • 🌐Global Functions
    • ⚙️Instances
      • 🔢Math
      • ☎️Events
        • event_t
      • 🎮Game
        • global_vars_t
        • cengine_client
          • cnet_chan
        • ccsgo_input
        • cinput_system
        • cgame_ui_funcs
        • ccvar
          • convar
      • 🕹️Mods
        • events_t
      • ✏️Draw
        • ⚙️Types
          • ⚙️rect
          • ⚙️vec2
          • ⚙️color
          • ⚙️accessor
        • 🖥️Adapter
        • ✏️Layer
          • outline_mode
          • rounding
          • glow_parts
          • text_params
            • text_alignment
          • shadow_dir
          • command
            • render_mode
        • 🖼️Managed
          • 🖼️texture
            • svg_texture
            • animated_texture
          • 🖼️shader
          • ™️font_base
            • font
            • font_gdi
            • glyph_t
            • font_flags
      • 🙋Entities
        • entity_list_t
          • entity_entry_t
        • base_entity
          • schema_accessor_t
          • cs2_weapon_base_gun
          • cs2_player_pawn
          • cs2_player_controller
          • cs2_weapon_base
          • cs2_grenade_projectile
        • ccsweapon_base_vdata
          • cfiring_mode
        • chandle
        • csweapon_mode
        • csweapon_type
        • weapon_id
        • csweapon_category
        • observer_mode_t
      • 🖥️Gui
        • ⚙️Types
          • ⚙️bits
          • ⚙️control_id
        • context
          • user_t
        • context_input
          • mouse_button
        • notification_system
          • notification
        • control
          • control_type
          • value_param
          • checkbox
          • slider
          • label
          • selectable
          • button
          • color_picker
          • spacer
          • text_input
          • combo_box
          • image
        • container
          • control_container
            • layout
            • group
      • ⚙️Utils
    • ⚙️Types
      • ⚙️ptr
      • ⚙️ref_holder_t
      • ⚙️vector
      • ⚙️vector4d
      • 🎮veccolor
      • 🎮color
      • 🎮cview_setup
      • 🎮cuser_cmd
      • 🎮game_event_t
    • 🟰Enums
      • 🟰client_frame_stage
      • 🟰input_bit_mask
Powered by GitBook

© 2025 - FATALITY

On this page
  • color
  • __call
  • white
  • white_transparent
  • black
  • black_transparent
  • percent
  • gray
  • interpolate
  • rgba
  • argb
  • bgra
  • abgr
  • darken
  • mod_a
  • r
  • g
  • b
  • a
  • get_r
  • get_g
  • get_b
  • get_a
  • h
  • s
  • v
  • hsv
Export as PDF
  1. API
  2. Instances
  3. Draw
  4. Types

color

color

Last modified: 03 January 2025

This type is a color used within the rendering system.

Do not mistake this type with color that is used in game! While these types are interchangeable internally, they are NOT in the API.

__call

Creates a new color instance.

Arguments

1. Default color (translucent black).

None.

2. Integer colors.

Name

Type

Description

r

int

Red color (0 to 255).

g

int

Green color (0 to 255).

b

int

Blue color (0 to 255).

a

int

Opacity (0 to 255). Defaults to 255.

3. Hex string.

Name

Type

Description

hex

string

Hex string. Formats are: #rrggbbaa, #rrggbb, #rgba and #rgb.

Returns

Type

Description

color

Color object.

Example

local white = draw.color(255, 255, 255);

white

Returns a white, opaque color.

Arguments

None.

Returns

Type

Description

color

Color object.

Example

local white = draw.color.white();

white_transparent

Returns a white, transparent color.

Arguments

None.

Returns

Type

Description

color

Color object.

Example

local white_t = draw.color.white_transparent();

black

Returns a black, opaque color.

Arguments

None.

Returns

Type

Description

color

Color object.

Example

local black = draw.color.black();

black_transparent

Returns a black, transparent color.

Arguments

None.

Returns

Type

Description

color

Color object.

Example

local black_t = draw.color.black_transparent();

percent

Returns a red-to-green color, depending on the provided percent.

Arguments

Name

Type

Description

p

float

Percentile (0 to 1).

a

float

Opacity. Defaults to 1.

Returns

Type

Description

color

Color object.

Example

local yellow = draw.color.percent(0.5);

gray

Returns a black-to-white color, depending on the provided percent.

Arguments

Name

Type

Description

b

float

Percentile (0 to 1).

a

float

Opacity. Defaults to 1.

Returns

Type

Description

color

Color object.

Example

local gray = draw.color.gray(0.5);

interpolate

Interpolates two colors.

Arguments

Name

Type

Description

a

color

Starting color.

b

color

Ending color.

t

float

Interpolation percentile.

Returns

Type

Description

color

Color object.

Example

local a = draw.color.white();
local b = draw.color.black();
local i = draw.color.interpolate(a, b, 0.5); -- gray

rgba

Returns integer representation of this color (RGBA format)

Arguments

None.

Returns

Type

Description

int

RGBA color.

Example

local num = col:rgba();

argb

Returns integer representation of this color (ARGB format)

Arguments

None.

Returns

Type

Description

int

ARGB color.

Example

local num = col:argb();

bgra

Returns integer representation of this color (BGRA format)

Arguments

None.

Returns

Type

Description

int

BGRA color.

Example

local num = col:bgra();

abgr

Returns integer representation of this color (ABGR format)

Arguments

None.

Returns

Type

Description

int

ABGR color.

Example

local num = col:abgr();

darken

Returns darker variant of this color.

Arguments

Name

Type

Description

value

float

Modulation amount (0 to 1).

Returns

Type

Description

color

Darker color.

Example

local darker = col:darken(0.5);

mod_a

Modulate opacity of the color. This will take existing opacity, and multiply it by whatever value you provide. It is useful if you want to modulate same color in steps, instead of setting the accurate opacity number.

Arguments

1. Float variant.

Name

Type

Description

value

float

Opacity modulation (0 to 1).

2. Integer variant.

Name

Type

Description

value

int

Opacity modulation (0 to 255).

Returns

Type

Description

color

Modulated color.

Example

local half_opacity = col:mod_a(0.5);

r

Override red and return new color.

Arguments

Name

Type

Description

value

float

New value.

Returns

Type

Description

color

New color.

Example

local full_red = col:r(1);

g

Override green and return new color.

Arguments

Name

Type

Description

value

float

New value.

Returns

Type

Description

color

New color.

Example

local full_green = col:g(1);

b

Override blue and return new color.

Arguments

Name

Type

Description

value

float

New value.

Returns

Type

Description

color

New color.

Example

local full_blue = col:b(1);

a

Override opacity and return new color.

Arguments

Name

Type

Description

value

float

New value.

Returns

Type

Description

color

New color.

Example

local full_opacity = col:a(1);

get_r

Returns red color value.

Arguments

None.

Returns

Type

Description

int

Color value.

Example

local r = col:get_r();

get_g

Returns green color value.

Arguments

None.

Returns

Type

Description

int

Color value.

Example

local g = col:get_g();

get_b

Returns blue color value.

Arguments

None.

Returns

Type

Description

int

Color value.

Example

local b = col:get_b();

get_a

Returns opacity color value.

Arguments

None.

Returns

Type

Description

int

Color value.

Example

local a = col:get_a();

h

Return hue value of the color.

Arguments

None.

Returns

Type

Description

int

Hue (0 to 359).

Example

local hue = col:h();

s

Returns saturation value of the color.

Arguments

None.

Returns

Type

Description

float

Saturation (0 to 1).

Example

local saturation = col:s();

v

Returns brightness value of the color.

Arguments

None.

Returns

Type

Description

float

Brightness (0 to 1).

Example

local brightness = col:v();

hsv

Construct new color from provided HSB values.

Arguments

Name

Type

Description

hue

int

Hue (0 to 359).

saturation

float

Saturation (0 to 1).

brightness

float

Brightness (0 to 1).

alpha

float

Override opacity of the source color. Must be either left out, or provided 0 to 1 value.

Returns

Type

Description

color

New color.

Example

local new_col = col:hsv(250, 0.5, 0.1);
Previousvec2Nextaccessor

Last updated 4 months ago

⚙️
✏️
⚙️
⚙️