⚙️vec2

__call

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

Type: float

X coordinate.


y

Type: float

Y coordinate.


floor

Returns floored variant of this vector.

Arguments

None.

Returns

Type

Description

vec2

Floored variant.

Example

local fl = vec:floor();

Returns ceiled variant of this vector.

Arguments

None.

Returns

Type

Description

vec2

Ceiled variant.

Example

local ceiled = vec:ceil();

round

Returns rounded variant of this vector.

Arguments

None.

Returns

Type

Description

vec2

Rounded variant.

Example

local rounded = vec:round();

len

Returns length of this vector.

Arguments

None.

Returns

Type

Description

float

Length.

Example

local len = vec:len();

len_sqr

Returns squared length of this vector.

This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.

Arguments

None.

Returns

Type

Description

float

Length.

Example

local len = vec:len_sqr();

dist

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

Returns squared distance to another vector.

This method is de-facto faster than the non-squared variant. Use it, if you need extra performance.

Arguments

Name

Type

Description

other

vec2

Other vector.

Returns

Type

Description

float

Distance.

Example

local dist = vec1:dist_sqr(vec2);

Last updated