Alternate name for the y component.
Returns the length of the vector.
Returns the squared length of the vector.
Alternate name for the x component.
x component of the vec2.
y component of the vec2.
Returns a copy of the vector with its length clamped to length.
Like distance(), but returns the squared distance between vectors.
StaticdownReturns the vector (0, -1).
StaticleftReturns the vector (-1, 0).
StaticlerpStaticmaxStaticminReturns a copy of the vector with its length scaled to 1.
StaticoneReturns the vector (1, 1).
StaticrandomGenerate a random 2D direction vector. This is equivalent to a random point on a unit-radius circle.
StaticrightReturns the vector (1, 0).
Returns a string representation of the vector.
StaticupReturns the vector (0, 1).
StaticzeroReturns the vector (0, 0).
A two dimensional vector. Vectors can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.
Example