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
  • __callīģŋ
  • minsīģŋ
  • maxsīģŋ
  • widthīģŋ
  • heightīģŋ
  • sizeīģŋ
  • explodeīģŋ
  • half_widthīģŋ
  • translateīģŋ
  • margin_leftīģŋ
  • margin_rightīģŋ
  • margin_topīģŋ
  • margin_bottomīģŋ
  • padding_leftīģŋ
  • padding_rightīģŋ
  • padding_topīģŋ
  • padding_bottomīģŋ
  • shrinkīģŋ
  • expandīģŋ
  • containsīģŋ
  • overlapsīģŋ
  • intersectīģŋ
  • tlīģŋ
  • trīģŋ
  • brīģŋ
  • blīģŋ
  • centerīģŋ
  • circleīģŋ
  • floorīģŋ
  • ceilīģŋ
  • roundīģŋ
  • is_zeroīģŋ
Export as PDF
  1. API
  2. Instances
  3. Draw
  4. Types

rect

__callīģŋ

Constructor

Creates a new rectangle.

Arguments

1. Default rectangle (0, 0 position; 0, 0 size).

None.

2. Single value.

Name
Type
Description

value

float

Mins XY, maxs XY value.

3. Single vector.

Name
Type
Description

value

Mins vector, maxs vector.

4. Double value.

Name
Type
Description

x

float

Mins/maxs X coordinate.

y

float

Mins/maxs Y coordinate.

5. Double vector.

Name
Type
Description

mins

Mins vector.

maxs

Maxs vector.

6. Four values.

Name
Type
Description

x0

float

Mins X coordinate.

y0

float

Mins Y coordinate.

x1

float

Maxs X coordinate.

y1

float

Maxs Y coordinate.

Returns

Type
Description

rect

New rectangle.

Example

local my_rect = draw.rect(50, 50, 150, 150);

minsīģŋ

Field

Mins (top-left) vector.


maxsīģŋ

Field

Maxs (bottom-right) vector.


widthīģŋ

Method

Either returns rectangle's width, or sets a new width.

Arguments

1. Get width.

None.

2. Set width.

Name
Type
Description

value

float

New width.

Returns

1. Get width.

Type
Description

float

Width.

2. Set width.

Type
Description

rect

New rectangle with changed width.

Example

local half_width = rect:width(rect:width() * 0.5);

heightīģŋ

Method

Either returns rectangle's height, or sets a new height.

Arguments

1. Get height.

None.

2. Set height.

Name
Type
Description

value

float

New height.

Returns

1. Get height.

Type
Description

float

Height.

2. Set height.

Type
Description

rect

New rectangle with changed height.

Example

local half_height = rect:height(rect:height() * 0.5);

sizeīģŋ

Method

Either returns rectangle's size, or sets a new size.

Arguments

1. Get size.

None.

2. Set size.

Name
Type
Description

value

New size.

Returns

1. Get size.

Type
Description

Size.

2. Set size.

Type
Description

rect

New rectangle with changed size.

Example

local half_size = rect:size(rect:size() * draw.vec2(0.5, 0.5));

explodeīģŋ

Method

Explodes the rectangle by given vector (increase size from center into all directions by coordinates in the vector).

Arguments

Name
Type
Description

value

Explode size.

Returns

Type
Description

rect

Exploded rectangle.

Example

local exp = rect:explode(draw.vec2(6, 6)); -- will subtract -3,-3 from mins and add 3,3 to maxs

half_widthīģŋ

Method

Returns a rectangle with half of the width of this rectangle.

Arguments

None.

Returns

Type
Description

rect

Rectangle with halved width.

Example

local half = rect:half_width();

translateīģŋ

Method

Translates (moves) this rectangle by vector coordinates.

Arguments

Name
Type
Description

value

Translation amount.

Returns

Type
Description

rect

Translated rectangle.

Example

local rect = draw.rect(50, 50, 150, 150);
local translated = rect:translate(draw.vec2(5, 5)); -- mins/maxs will be 55,55 and 155,155

margin_leftīģŋ

Method

Move rectangle from the left by given amount.

Arguments

Name
Type
Description

value

float

Margin amount.

Returns

Type
Description

rect

Moved rectangle.

Example

local new = rect:margin_left(5); -- moves to the right by 5px

margin_rightīģŋ

Method

Move rectangle from the right by given amount.

Arguments

Name
Type
Description

value

float

Margin amount.

Returns

Type
Description

rect

Moved rectangle.

Example

local new = rect:margin_right(5); -- moves to the left by 5px

margin_topīģŋ

Method

Move rectangle from the top by given amount.

Arguments

Name
Type
Description

value

float

Margin amount.

Returns

Type
Description

rect

Moved rectangle.

Example

local new = rect:margin_top(5); -- moves to the bottom by 5px

margin_bottomīģŋ

Method

Move rectangle from the bottom by given amount.

Arguments

Name
Type
Description

value

float

Margin amount.

Returns

Type
Description

rect

Moved rectangle.

Example

local new = rect:margin_bottom(5); -- moves to the top by 5px

padding_leftīģŋ

Method

Adds the value to the left side of the rectangle.

Arguments

Name
Type
Description

value

float

Padding amount.

Returns

Type
Description

rect

Resized rectangle.

Example

local new = rect:padding_left(5); -- adds 5 to mins x

padding_rightīģŋ

Method

Adds the value to the right side of the rectangle.

Arguments

Name
Type
Description

value

float

Padding amount.

Returns

Type
Description

rect

Resized rectangle.

Example

local new = rect:padding_right(5); -- adds 5 to maxs x

padding_topīģŋ

Method

Adds the value to the top side of the rectangle.

Arguments

Name
Type
Description

value

float

Padding amount.

Returns

Type
Description

rect

Resized rectangle.

Example

local new = rect:padding_top(5); -- adds 5 to mins y

padding_bottomīģŋ

Method

Adds the value to the bottom side of the rectangle.

Arguments

Name
Type
Description

value

float

Padding amount.

Returns

Type
Description

rect

Resized rectangle.

Example

local new = rect:padding_bottom(5); -- adds 5 to maxs y

shrinkīģŋ

Method

Shrinks (implodes) the rectangle by given amount.

Arguments

Name
Type
Description

value

float

Shrink value.

Returns

Type
Description

rect

Resized rectangle.

Example

local shrinked = rect:shrink(5); -- adds 5,5 to mins and subtracts 5,5 from maxs

expandīģŋ

Method

Expands (explodes) the rectangle by given amount.

Arguments

Name
Type
Description

value

float

Expand value.

Returns

Type
Description

rect

Resized rectangle.

Example

local expanded = rect:expand(5); -- subtracts 5,5 from mins and adds 5,5 to maxs

containsīģŋ

Method

Returns true if this rectangle contains either vector or another rectangle.

Rectangle overload will return true ONLY of entire other rectangle is within the bounds of this one.

Arguments

1. Vector variant.

Name
Type
Description

other

Vector to check against.

2. Rectangle variant.

Name
Type
Description

other

rect

Rectangle to check against.

Returns

Type
Description

bool

true if other object is in bounds of this rectangle.

Example

if rect:contains(cursor_pos) then
    -- ...
end

overlapsīģŋ

Method

Returns true if the other rectangle overlaps with this rectangle.

Arguments

Name
Type
Description

other

rect

Rectangle to check against.

Returns

Type
Description

bool

true if other rectangle overlaps with this rectangle.

Example

if rect:overlaps(another_rect) then
    -- ...
end

intersectīģŋ

Method

Intersects this rectangle with another rectangle.

Arguments

Name
Type
Description

other

rect

Rectangle to intersect with.

Returns

Type
Description

rect

Intersected rectangle.

Example

local intersected = rect:intersect(another_rect);

tlīģŋ

Method

Returns top-left vector.

Arguments

None.

Returns

Type
Description

Top-left vector.

Example

local tl = rect:tl();

trīģŋ

Method

Returns top-right vector.

Arguments

None.

Returns

Type
Description

Top-right vector.

Example

local tr = rect:tr();

brīģŋ

Method

Returns bottom-right vector.

Arguments

None.

Returns

Type
Description

Bottom-right vector.

Example

local br = rect:br();

blīģŋ

Method

Returns bottom-left vector.

Arguments

None.

Returns

Type
Description

Bottom-left vector.

Example

local bl = rect:bl();

centerīģŋ

Method

Returns center point of this rectangle.

Arguments

None.

Returns

Type
Description

Center point.

Example

local center = rect:center();

circleīģŋ

Method

Treats this rectangle as an ellipsis and returns point on it. Note, that this "ellipsis" will be perfect with no modified curvature (basically if this rectangle is a box - you will get a point on a perfect circle).

Arguments

Name
Type
Description

r

float

Radians value.

Returns

Type
Description

Point on the ellipsis.

Example

local point = rect:circle(rad(250)); -- returns point on the 250th degree

floorīģŋ

Method

Returns floored rectangle.

Arguments

None.

Returns

Type
Description

rect

Floored rectangle.

Example

local floored = rect:floor();

ceilīģŋ

Method

Returns ceiled rectangle.

Arguments

None.

Returns

Type
Description

rect

Ceiled rectangle.

Example

local ceiled = rect:ceil();

roundīģŋ

Method

Returns rounded rectangle.

Arguments

None.

Returns

Type
Description

rect

Rounded rectangle.

Example

local rounded = rect:round();

is_zeroīģŋ

Method

Returns true if both mins and maxs are equal to 0.

Arguments

None.

Returns

Type
Description

bool

true if this is a zero rectangle.

Example

if rect:is_zero() then
    -- ...
end
PreviousTypesNextvec2

Last updated 2 months ago

Type:

Type:

âš™ī¸
âœī¸
âš™ī¸
âš™ī¸
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2
vec2