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
  • gīģŋ
  • fontīģŋ
  • tex_szīģŋ
  • skip_dpiīģŋ
  • add_triangle_filledīģŋ
  • add_quad_filledīģŋ
  • add_rect_filledīģŋ
  • add_circle_filledīģŋ
  • add_triangle_filled_multicolorīģŋ
  • add_rect_filled_multicolorīģŋ
  • add_circle_filled_multicolorīģŋ
  • add_quad_filled_multicolorīģŋ
  • add_pill_multicolorīģŋ
  • add_shadow_lineīģŋ
  • add_shadow_rectīģŋ
  • add_glowīģŋ
  • add_rect_filled_roundedīģŋ
  • add_rect_filled_rounded_multicolorīģŋ
  • add_triangleīģŋ
  • add_quadīģŋ
  • add_rectīģŋ
  • add_circleīģŋ
  • add_lineīģŋ
  • add_line_multicolorīģŋ
  • add_rect_roundedīģŋ
  • add_textīģŋ
  • override_clip_rectīģŋ
Export as PDF
  1. API
  2. Instances
  3. Draw

Layer

PreviousAdapterNextoutline_mode

Last updated 3 months ago

A layer is a type that is used to store render commands, as well as vertex and index data. This is the only way to push shapes and control rendering state.

gīģŋ

Type:

The next render command to be pushed to the queue. This is the object you want to change to, for example, set a texture, or change rendering modes.


fontīģŋ

Type:

Font to use with add_text. If nothing has been set, no text will get rendered.


tex_szīģŋ

Type:

Texture dimensions. This value is only required if you are trying to render rounded shapes with a texture, so the rendering system will correctly map your UV coordinates to whatever shape you are rendering.


skip_dpiīģŋ

Type: bool

If set to true, will skip global DPI scale. Defaults to true.


add_triangle_filledīģŋ

Adds a filled triangle with a single color.

Arguments

Name

Type

Description

a

A point.

b

B point.

c

C point.

col

Shape color.

Returns

Nothing.

Example

layer:add_triangle_filled(
    draw.vec2(50, 50), draw.vec2(25, 75),
    draw.vec2(75, 75), draw.color(255, 255, 255));

add_quad_filledīģŋ

Adds a filled quad with a single color.

Arguments

Name

Type

Description

tl

Top left point.

tr

Top right point.

br

Bottom right point.

bl

Bottom left point.

col

Shape color.

Returns

Nothing.

Example

layer:add_quad_filled(
    draw.vec2(50, 50), draw.vec2(100, 60),
    draw.vec2(100, 100), draw.vec2(30, 70),
    draw.color(255, 255, 255));

add_rect_filledīģŋ

Adds a filled rectangle with a single color.

Arguments

Name

Type

Description

r

Rectangle.

col

Shape color.

Returns

Nothing.

Example

layer:add_rect_filled(draw.rect(50, 50, 150, 150), draw.color(255, 255, 255));

add_circle_filledīģŋ

Adds a filled circle with a single color.

Arguments

Name

Type

Description

center

Center point.

radius

float

Circle radius.

c

Shape color.

segments

int

Circle segments. If set to 0, will attempt automatic segment deduction. Defaults to 0.

fill

float

Fill amount (clockwise, 0 to 1). Defaults to 1.

Returns

Nothing.

Example

layer:add_circle_filled(draw.vec2(50, 50), 10, draw.color(255, 255, 255));

add_triangle_filled_multicolorīģŋ

Adds a filled, multicolor triangle.

Arguments

Name

Type

Description

a

A point.

b

B point.

c

C point.

cols

table[color, color, color]

Colors for each point. Colors go in the very same order as the parameter list.

Returns

Nothing.

Example

layer:add_triangle_filled_multicolor(
     draw.vec2(50, 50), draw.vec2(25, 75),
     draw.vec2(75, 75), {
        draw.color(255, 0, 0),
        draw.color(0, 255, 0),
        draw.color(0, 0, 255)
     });

add_rect_filled_multicolorīģŋ

Adds a filled, multicolor rectangle.

Arguments

Name

Type

Description

r

Rectangle.

cols

table[color, color, color, color]

Colors for each corner of the rectangle, in clockwise order starting from top-left.

Returns

Nothing.

Example

layer:add_rect_filled_multicolor(
    draw.rect(50, 50, 150, 150), {
        draw.color(255, 0, 0),
        draw.color(0, 255, 0),
        draw.color(0, 0, 255),
        draw.color(255, 255, 0)
    });

add_circle_filled_multicolorīģŋ

Adds a filled, multicolor circle.

Arguments

Name

Type

Description

center

Center point.

radius

float

Circle radius.

cols

table[color, color]

Colors for the gradient, starting with the inner and ending with the outer color.

segments

int

The number of segments to approximate the circle. Defaults to 36.

fill

float

The portion of the circle to fill, where 1.0 is a full circle. Defaults to 1.0.

Returns

Nothing.

Example

layer:add_circle_filled_multicolor(
    draw.vec2(100, 100), 50, {
        draw.color(255, 0, 0),
        draw.color(0, 0, 255)
    }, 36, 1.0);

add_quad_filled_multicolorīģŋ

Adds a filled, multicolor quad.

Arguments

Name

Type

Description

tl

Top left point.

tr

Top right point.

br

Bottom right point.

bl

Bottom left point.

cols

table[color, color]

Colors for the gradient, applied from bottom to top.

Returns

Nothing.

Example

layer:add_quad_filled_multicolor(
    draw.vec2(50, 50), draw.vec2(150, 50),
    draw.vec2(150, 150), draw.vec2(50, 150), {
        draw.color(255, 0, 0),
        draw.color(0, 0, 255)
    });

add_pill_multicolorīģŋ

Adds a multicolor pill shape.

Arguments

Name

Type

Description

mins

Top left point of the pill.

maxs

Bottom right point of the pill.

radius_min

float

The minimum radius of the pill's rounded edges.

radius_max

float

The maximum radius of the pill's rounded edges.

cols

table[color, color]

Colors for the gradient, applied from bottom to top.

segments

int

The number of segments for approximating rounded edges. Defaults to 16.

Returns

Nothing.

Example

layer:add_pill_multicolor(
    draw.vec2(50, 50), draw.vec2(150, 100),
    10, 20, {
        draw.color(255, 0, 0),
        draw.color(0, 0, 255)
    }, 16);

add_shadow_lineīģŋ

Adds a shadow line.

Arguments

Name

Type

Description

r

Bounding box for the shadow line.

dir

Shadow direction.

a

float

Max opacity. Defaults to 0.25.

Returns

Nothing.

Example

layer:add_shadow_line(
    draw.rect(50, 50, 150, 150), draw.shadow_dir.down, 0.25);

add_shadow_rectīģŋ

Adds a shadowed rectangle.

Arguments

Name

Type

Description

r

Rectangle.

radius

float

Shadow distance, in pixels, outwards.

bg

bool

Whether to draw a background for the rectangle. Defaults to true.

a

float

Max opacity of the shadow. Defaults to 0.25.

Returns

Nothing.

Example

layer:add_shadow_rect(
    draw.rect(50, 50, 150, 150), 15, true, 0.25);

add_glowīģŋ

Adds a glow box.

Arguments

Name

Type

Description

r

Box rectangle.

radius

float

Glow distance, in pixels, outwards.

c

Glow color.

parts

Parts of the glow to enable. Defaults to all.

Returns

Nothing.

Example

layer:add_glow(draw.rect(50, 50, 150, 150), 15, draw.color(255, 0, 0));

add_rect_filled_roundedīģŋ

Adds a filled, rounded rectangle.

Arguments

Name

Type

Description

r

Rectangle.

c

Fill color.

amount

float

Rounding amount.

rnd

Rounding mode. Defaults to all.

Returns

Nothing.

Example

layer:add_rect_filled_rounded(
    draw.rect(50, 50, 150, 150),
    draw.color(255, 0, 0),
    10,
    draw.rounding.all
);

add_rect_filled_rounded_multicolorīģŋ

Adds a filled, multicolor rounded rectangle.

Arguments

Name

Type

Description

r

Rectangle.

c

table[color, color, color, color]

Fill colors. Used clockwise, starting from top left.

amount

float

Rounding amount.

rnd

Rounding mode. Defaults to all.

Returns

Nothing.

Example

layer:add_rect_filled_rounded_multicolor(
    draw.rect(50, 50, 150, 150), {
        draw.color(255, 0, 0),
        draw.color(0, 255, 0),
        draw.color(0, 0, 255),
        draw.color(255, 255, 0)
    },
    10,
    draw.rounding.all
);

add_triangleīģŋ

Adds a stroked triangle.

Arguments

Name

Type

Description

a

Point A.

b

Point B.

c

Point C.

col

Line color.

thickness

float

Line thickness. Defaults to 1.0.

mode

Outline mode. Defaults to inset.

Returns

Nothing.

Example

layer:add_triangle(
    draw.vec2(50, 50),
    draw.vec2(25, 75),
    draw.vec2(75, 75),
    draw.color(255, 0, 0),
    1.0,
    draw.outline_mode.inset
);

add_quadīģŋ

Adds a stroked quad.

Arguments

Name

Type

Description

tl

Top-left point.

tr

Top-right point.

br

Bottom-right point.

bl

Bottom-left point.

c

Line color.

thickness

float

Line thickness. Defaults to 1.0.

mode

Outline mode. Defaults to inset.

Returns

Nothing.

Example

layer:add_quad(
    draw.vec2(50, 50),
    draw.vec2(150, 50),
    draw.vec2(150, 150),
    draw.vec2(50, 150),
    draw.color(255, 0, 0),
    1.0,
    draw.outline_mode.inset
);

add_rectīģŋ

Adds a stroked rectangle.

Arguments

Name

Type

Description

r

Rectangle.

c

Line color.

thickness

float

Line thickness. Defaults to 1.0.

mode

Outline mode. Defaults to inset.

Returns

Nothing.

Example

layer:add_rect(
    draw.rect(50, 50, 150, 150),
    draw.color(255, 0, 0),
    1.0,
    draw.outline_mode.inset
);

add_circleīģŋ

Adds a stroked circle.

Arguments

Name

Type

Description

center

Center point.

radius

float

Circle radius.

c

Line color.

segments

int

Circle segments. Defaults to 36.

fill

float

Fill amount. Defaults to 1.0.

thickness

float

Line thickness. Defaults to 1.0.

mode

Outline mode. Defaults to inset.

Returns

Nothing.

Example

layer:add_circle(
    draw.vec2(100, 100),
    50,
    draw.color(255, 0, 0),
    36,
    1.0,
    1.0,
    draw.outline_mode.inset
);

add_lineīģŋ

Adds a line.

Arguments

Name

Type

Description

a

Start point.

b

End point.

c

Line color.

thickness

float

Line thickness. Defaults to 1.0

Returns

Nothing.

Example

layer:add_line(
    draw.vec2(50, 50),
    draw.vec2(150, 150),
    draw.color(255, 0, 0)
);

add_line_multicolorīģŋ

Adds a multicolor line.

Arguments

Name

Type

Description

a

Start point.

b

End point.

c

Start color.

c2

End color.

thickness

float

Line thickness. Defaults to 1.0.

Returns

Nothing.

Example

layer:add_line_multicolor(
    draw.vec2(50, 50),
    draw.vec2(150, 150),
    draw.color(255, 0, 0),
    draw.color(0, 0, 255),
    2.0
);

add_rect_roundedīģŋ

Adds a rounded, filled rectangle.

Arguments

Name

Type

Description

r

Rectangle.

c

Line color.

amount

float

Rounding amount.

rnd

Rounding mode. Defaults to all.

thickness

float

Line thickness. Defaults to 1.0.

mode

Outline mode. Defaults to inset.

Returns

Nothing.

Example

layer:add_rect_rounded(draw.rect(50, 50, 150, 150),
    draw.color(255, 255, 255), 14);

add_textīģŋ

Adds text.

If font wasn't set, this function will do nothing.

You can control the color while rendering the text. To change the color, add \fRRGGBBAA to the string. To reset the color, add \b.

Arguments

Name

Type

Description

p

Text origin point.

text

string

Text.

c

Text color.

params

Text aligning parameters. Defaults to nil.

Returns

Nothing.

Example

layer:add_text(draw.vec2(50, 50), 'Hello world!', draw.color(255, 255, 255));

override_clip_rectīģŋ

Overrides clip rectangle with support of intersection.

Arguments

Name

Type

Description

r

New clip rect.

intersect

bool

Whether this function should intersect previous rect with the new one. Defaults to true.

Returns

Nothing.

Example

layer:override_clip_rect(draw.rect(50, 50, 150, 150));

âš™ī¸
âœī¸
âœī¸
command
font_base
vec2?
vec2
vec2
vec2
color
vec2
vec2
vec2
vec2
color
rect
color
vec2
color
vec2
vec2
vec2
rect
vec2
vec2
vec2
vec2
vec2
vec2
vec2
rect
shadow_dir
rect
rect
color
glow_parts
rect
color
rounding
rect
rounding
vec2
vec2
vec2
color
outline_mode
vec2
vec2
vec2
vec2
color
outline_mode
rect
color
outline_mode
vec2
color
outline_mode
vec2
vec2
color
vec2
vec2
color
color
rect
color
rounding
outline_mode
vec2
color
text_params?
rect?