Skip to main content
A 2D vector for screen positions and sizes, in pixels with y pointing down. Global class, no import.
Fields are 32-bit floats; assigning a non-number or NaN throws. A Vector is accepted too and gives its x and y. To get a screen position from a world one, use render.worldToScreen.

Overview

Common

from, set, add, lerp, normalize…

Length and distance

length, distTo, dot, cross.

Rotation

rotated.

Common

Every argument takes any Vec2Like, not just a Vector2. Only set() and normalize() change the value. Nothing changes its arguments.

Length and distance


Rotation

rotated


A copy rotated around pivot (default (0, 0)). Positive degrees turn clockwise on screen, because y points down.

Example

An arrow at the edge of a circle around the crosshair, pointing at a target’s world position.