Skip to Content

@revideo/core


@revideo/core / types / Vector2

Class: Vector2

Defined in: types/Vector.ts:34 

Represents a two-dimensional vector.

Implements

Constructors

Constructor

new Vector2(): Vector2

Defined in: types/Vector.ts:343 

Returns

Vector2

Constructor

new Vector2(from): Vector2

Defined in: types/Vector.ts:344 

Parameters

from

PossibleVector2

Returns

Vector2

Constructor

new Vector2(x, y): Vector2

Defined in: types/Vector.ts:345 

Parameters

x

number

y

number

Returns

Vector2

Properties

x

x: number = 0

Defined in: types/Vector.ts:69 


y

y: number = 0

Defined in: types/Vector.ts:70 


bottom

readonly static bottom: Vector2

Defined in: types/Vector.ts:51 

A constant equal to Vector2(0, 1)


bottomLeft

readonly static bottomLeft: Vector2

Defined in: types/Vector.ts:63 

A constant equal to Vector2(-1, 1)


bottomRight

readonly static bottomRight: Vector2

Defined in: types/Vector.ts:67 

A constant equal to Vector2(1, 1)


down

readonly static down: Vector2

Defined in: types/Vector.ts:42 


left

readonly static left: Vector2

Defined in: types/Vector.ts:40 


one

readonly static one: Vector2

Defined in: types/Vector.ts:38 


readonly static right: Vector2

Defined in: types/Vector.ts:39 


symbol

readonly static symbol: typeof symbol

Defined in: types/Vector.ts:35 


top

readonly static top: Vector2

Defined in: types/Vector.ts:47 

A constant equal to Vector2(0, -1)


topLeft

readonly static topLeft: Vector2

Defined in: types/Vector.ts:55 

A constant equal to Vector2(-1, -1)


topRight

readonly static topRight: Vector2

Defined in: types/Vector.ts:59 

A constant equal to Vector2(1, -1)


up

readonly static up: Vector2

Defined in: types/Vector.ts:41 


zero

readonly static zero: Vector2

Defined in: types/Vector.ts:37 

Accessors

ctg

Get Signature

get ctg(): number

Defined in: types/Vector.ts:340 

Returns

number


degrees

Get Signature

get degrees(): number

Defined in: types/Vector.ts:336 

Return the angle in degrees between the vector and the positive x-axis.

Remarks

The returned angle will be between -180 and 180 degrees.

Returns

number


flipped

Get Signature

get flipped(): Vector2

Defined in: types/Vector.ts:311 

Returns

Vector2


floored

Get Signature

get floored(): Vector2

Defined in: types/Vector.ts:315 

Returns

Vector2


height

Get Signature

get height(): number

Defined in: types/Vector.ts:287 

Returns

number

Set Signature

set height(value): void

Defined in: types/Vector.ts:291 

Parameters
value

number

Returns

void


magnitude

Get Signature

get magnitude(): number

Defined in: types/Vector.ts:295 

Returns

number


normalized

Get Signature

get normalized(): Vector2

Defined in: types/Vector.ts:303 

Returns

Vector2


perpendicular

Get Signature

get perpendicular(): Vector2

Defined in: types/Vector.ts:319 

Returns

Vector2


radians

Get Signature

get radians(): number

Defined in: types/Vector.ts:326 

Return the angle in radians between the vector and the positive x-axis.

Returns

number


safe

Get Signature

get safe(): Vector2

Defined in: types/Vector.ts:307 

Returns

Vector2


squaredMagnitude

Get Signature

get squaredMagnitude(): number

Defined in: types/Vector.ts:299 

Returns

number


width

Get Signature

get width(): number

Defined in: types/Vector.ts:279 

Returns

number

Set Signature

set width(value): void

Defined in: types/Vector.ts:283 

Parameters
value

number

Returns

void

Methods

add()

add(possibleVector): Vector2

Defined in: types/Vector.ts:400 

Parameters

possibleVector

PossibleVector2

Returns

Vector2


addX()

addX(value): Vector2

Defined in: types/Vector.ts:425 

Parameters

value

number

Returns

Vector2


addY()

addY(value): Vector2

Defined in: types/Vector.ts:429 

Parameters

value

number

Returns

Vector2


cross()

cross(possibleVector): number

Defined in: types/Vector.ts:415 

Parameters

possibleVector

PossibleVector2

Returns

number


div()

div(possibleVector): Vector2

Defined in: types/Vector.ts:395 

Parameters

possibleVector

PossibleVector2

Returns

Vector2


dot()

dot(possibleVector): number

Defined in: types/Vector.ts:410 

Parameters

possibleVector

PossibleVector2

Returns

number


equals()

equals(other, threshold?): boolean

Defined in: types/Vector.ts:476 

Check if two vectors are equal to each other.

Parameters

other

Vector2

The vector to compare.

threshold?

number = EPSILON

The allowed error threshold when comparing the vectors.

Returns

boolean

Remarks

This method allows passing an allowed error margin when comparing vectors to compensate for floating point inaccuracies. To check if two vectors are exactly equal, use the exactlyEquals method, instead.


exactlyEquals()

exactlyEquals(other): boolean

Defined in: types/Vector.ts:461 

Check if two vectors are exactly equal to each other.

Parameters

other

Vector2

The vector to compare.

Returns

boolean

Remarks

If you need to compensate for floating point inaccuracies, use the equals method, instead.


getOriginOffset()

getOriginOffset(origin): Vector2

Defined in: types/Vector.ts:378 

Parameters

origin

Direction | Origin

Returns

Vector2


lerp()

lerp(to, value): Vector2

Defined in: types/Vector.ts:374 

Parameters

to

Vector2

value

number | Vector2

Returns

Vector2


mod()

mod(possibleVector): Vector2

Defined in: types/Vector.ts:420 

Parameters

possibleVector

PossibleVector2

Returns

Vector2


mul()

mul(possibleVector): Vector2

Defined in: types/Vector.ts:390 

Parameters

possibleVector

PossibleVector2

Returns

Vector2


scale()

scale(value): Vector2

Defined in: types/Vector.ts:386 

Parameters

value

number

Returns

Vector2


serialize()

serialize(): SerializedVector2

Defined in: types/Vector.ts:448 

Returns

SerializedVector2


sub()

sub(possibleVector): Vector2

Defined in: types/Vector.ts:405 

Parameters

possibleVector

PossibleVector2

Returns

Vector2


toString()

toString(): string

Defined in: types/Vector.ts:437 

Returns a string representation of an object.

Returns

string


toSymbol()

toSymbol(): symbol

Defined in: types/Vector.ts:433 

Returns

symbol

Implementation of

Type.toSymbol


toUniform()

toUniform(gl, location): void

Defined in: types/Vector.ts:441 

Parameters

gl

WebGL2RenderingContext

location

WebGLUniformLocation

Returns

void

Implementation of

WebGLConvertible.toUniform


angleBetween()

static angleBetween(u, v): number

Defined in: types/Vector.ts:272 

Parameters

u

Vector2

v

Vector2

Returns

number


arcLerp()

static arcLerp(from, to, value, reverse?, ratio?): Vector2

Defined in: types/Vector.ts:100 

Parameters

from

Vector2

to

Vector2

value

number

reverse?

boolean = false

ratio?

number

Returns

Vector2


createArcLerp()

static createArcLerp(reverse?, ratio?): (from, to, value) => Vector2

Defined in: types/Vector.ts:111 

Parameters

reverse?

boolean

ratio?

number

Returns

(from, to, value) => Vector2


createPolarLerp()

static createPolarLerp(counterclockwise?, center?): (from, to, value) => Vector2

Defined in: types/Vector.ts:197 

Helper function to create a Vector2.polarLerp interpolation function with additional parameters.

Parameters

counterclockwise?

boolean = false

Whether the point should get rotated counterclockwise.

center?

PossibleVector2 = Vector2.zero

The center of rotation. Defaults to the origin.

Returns

(from, to, value) => Vector2


createSignal()

static createSignal(initial?, interpolation?, owner?): Vector2Signal<void>

Defined in: types/Vector.ts:72 

Parameters

initial?

SignalValue<PossibleVector2<number>>

interpolation?

InterpolationFunction<Vector2> = Vector2.lerp

owner?

any

Returns

Vector2Signal<void>


degrees()

static degrees(x, y): number

Defined in: types/Vector.ts:260 

Return the angle in degrees between the vector described by x and y and the positive x-axis.

Parameters

x

number

The x component of the vector.

y

number

The y component of the vector.

Returns

number

Remarks

The returned angle will be between -180 and 180 degrees.


fromDegrees()

static fromDegrees(degrees): Vector2

Defined in: types/Vector.ts:235 

Parameters

degrees

number

Returns

Vector2


fromOrigin()

static fromOrigin(origin): Vector2

Defined in: types/Vector.ts:205 

Parameters

origin

Direction | Origin

Returns

Vector2


fromRadians()

static fromRadians(radians): Vector2

Defined in: types/Vector.ts:231 

Parameters

radians

number

Returns

Vector2


fromScalar()

static fromScalar(value): Vector2

Defined in: types/Vector.ts:227 

Parameters

value

number

Returns

Vector2


lerp()

static lerp(from, to, value): Vector2

Defined in: types/Vector.ts:86 

Parameters

from

Vector2

to

Vector2

value

number | Vector2

Returns

Vector2


magnitude()

static magnitude(x, y): number

Defined in: types/Vector.ts:264 

Parameters

x

number

y

number

Returns

number


polarLerp()

static polarLerp(from, to, value, counterclockwise?, origin?): Vector2

Defined in: types/Vector.ts:162 

Interpolates between two vectors on the polar plane by interpolating the angles and magnitudes of the vectors individually.

Parameters

from

Vector2

The starting vector.

to

Vector2

The target vector.

value

number

The t-value of the interpolation.

counterclockwise?

boolean = false

Whether the vector should get rotated counterclockwise. Defaults to false.

origin?

Vector2 = Vector2.zero

The center of rotation. Defaults to the origin.

Returns

Vector2

Remarks

This function is useful when used in conjunction with rotate to animate an object’s position on a circular arc (see examples).

Examples

Animating an object in a circle around the origin

circle().position( circle().position().rotate(180), 1, easeInOutCubic, Vector2.polarLerp );

Rotating an object around the point [-200, 100]

circle().position( circle().position().rotate(180, [-200, 100]), 1, easeInOutCubic, Vector2.createPolarLerp(false, [-200, 100]), );

Rotating an object counterclockwise around the origin

circle().position( circle().position().rotate(180), 1, easeInOutCubic, Vector2.createPolarLerp(true), );

radians()

static radians(x, y): number

Defined in: types/Vector.ts:246 

Return the angle in radians between the vector described by x and y and the positive x-axis.

Parameters

x

number

The x component of the vector.

y

number

The y component of the vector.

Returns

number


squaredMagnitude()

static squaredMagnitude(x, y): number

Defined in: types/Vector.ts:268 

Parameters

x

number

y

number

Returns

number

© 2026 Haven Technologies, Inc.
Class: Vector2 – Revideo