Vector2Extension extension

on

Methods

isIdentity() bool
Whether the Vector2 is the identity vector or not
isZero() bool
Whether the Vector2 is the zero vector or not
lerp(Vector2 to, double t) → void
Linearly interpolate towards another Vector2
moveToTarget(Vector2 target, double ds) → void
Smoothly moves this Vector2 in the direction target by a displacement given by a distance ds in that direction.
rotate(double angle, {Vector2? center}) → void
Rotates the Vector2 with angle in radians rotates around center if it is defined In a screen coordinate system (where the y-axis is flipped) it rotates in a clockwise fashion In a normal coordinate system it rotates in a counter-clockwise fashion
scaleTo(double newLength) → void
Changes the length of the vector to the length provided, without changing direction.
screenAngle() double
Signed angle in a coordinate system where the Y-axis is flipped.
toOffset() Offset
Creates an Offset from the Vector2
toPoint() Point<num>
Creates a Point from the Vector2
toPositionedRect(Vector2 size) Rect
Creates a Rect starting from (x, y) and having the size of the argument Vector2
toRect() Rect
Creates a Rect starting in origin and going the Vector2
toSize() Size
Creates a Size from the Vector2

Operators

operator %(Vector2 mod) Vector2
Modulo/Remainder
operator &(Vector2 size) Rect
A rectangle constructor operator.

Static Methods

fromDegrees(double d) Vector2
Creates a heading Vector2 with the given angle in degrees.
fromInts(int x, int y) Vector2
Create a Vector2 with ints as input
fromRadians(double r) Vector2
Creates a heading Vector2 with the given angle in radians.
identity() Vector2
Creates a new identity Vector2 (1.0, 1.0).