⚙️vec2
__call
Constructor
Creates a new 2D vector instance.
Arguments
1. Default vector (0, 0).
None.
2. Single value.
Name
Type
Description
value
float
X and Y coordinates.
3. XY values.
Name
Type
Description
x
float
X coordinate.
y
float
Y coordinate.
Returns
Type
Description
vec2
New vector.
Example
local vec = draw.vec2(5, 10);x
Field
Type: float
X coordinate.
y
Field
Type: float
Y coordinate.
floor
Method
Returns floored variant of this vector.
Arguments
None.
Returns
Type
Description
vec2
Floored variant.
Example
local fl = vec:floor();Method
Returns ceiled variant of this vector.
Arguments
None.
Returns
Type
Description
vec2
Ceiled variant.
Example
local ceiled = vec:ceil();round
Method
Returns rounded variant of this vector.
Arguments
None.
Returns
Type
Description
vec2
Rounded variant.
Example
local rounded = vec:round();len
Method
Returns length of this vector.
Arguments
None.
Returns
Type
Description
float
Length.
Example
local len = vec:len();len_sqr
Method
Returns squared length of this vector.
Arguments
None.
Returns
Type
Description
float
Length.
Example
local len = vec:len_sqr();dist
Method
Returns distance to another vector.
Arguments
Name
Type
Description
other
vec2
Other vector.
Returns
Type
Description
float
Distance.
Example
local dist = vec1:dist(vec2);dist_sqr
Method
Returns squared distance to another vector.
Arguments
Name
Type
Description
other
vec2
Other vector.
Returns
Type
Description
float
Distance.
Example
local dist = vec1:dist_sqr(vec2);Last updated