Vec2
Represents a 2D vector with x and y components. Used throughout the SDK for screen coordinates, UI positioning, 2D mathematical operations, and coordinate system conversions.
Type Definition
interface Vec2 {
x: number;
y: number;
}
Properties
- x: The horizontal coordinate or x-component of the vector
- y: The vertical coordinate or y-component of the vector
Examples
Basic Usage
// Screen coordinates
const mousePosition: Vec2 = {x: 150, y: 200};
const screenCenter: Vec2 = {x: 1920 / 2, y: 1080 / 2};
// 2D offset or direction
const offset: Vec2 = {
x: mousePosition.x - screenCenter.x,
y: mousePosition.y - screenCenter.y
};
Related Types
- Vec3 - 3D vector extension of Vec2
- Transform - Uses Vec3 internally for translation
- Rect - Uses Vec2 concepts for 2D bounds