Vector2Extension extension
- on
Methods
-
clamp(
Vector2 min, Vector2 max) → void -
Available on Vector2, provided by the Vector2Extension extension
Clamps this vector so that it is within or equals to the bounds defined bymin
andmax
. -
clampLength(
double min, double max) → void -
Available on Vector2, provided by the Vector2Extension extension
Clamps the length of this vector. -
invert(
) → void -
Available on Vector2, provided by the Vector2Extension extension
Inverts the vector. -
inverted(
) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Returns the inverse of this vector. -
isIdentity(
) → bool -
Available on Vector2, provided by the Vector2Extension extension
Whether the Vector2 is the identity vector or not -
isZero(
) → bool -
Available on Vector2, provided by the Vector2Extension extension
Whether the Vector2 is the zero vector or not -
lerp(
Vector2 to, double t) → void -
Available on Vector2, provided by the Vector2Extension extension
Linearly interpolate towards another Vector2 -
moveToTarget(
Vector2 target, double ds) → void -
Available on Vector2, provided by the Vector2Extension extension
Smoothly moves this Vector2 in the directiontarget
by a displacement given by a distanceds
in that direction. -
projection(
Vector2 other, {Vector2? out}) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Project this ontoother
. -
rotate(
double angle, {Vector2? center}) → void -
Available on Vector2, provided by the Vector2Extension extension
Rotates the Vector2 withangle
in radians rotates aroundcenter
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 -
Available on Vector2, provided by the Vector2Extension extension
Changes the length of the vector to the length provided, without changing direction. -
screenAngle(
) → double -
Available on Vector2, provided by the Vector2Extension extension
Signed angle in a coordinate system where the Y-axis is flipped. -
setAll(
double value) → void -
Available on Vector2, provided by the Vector2Extension extension
Sets both x and y tovalue
. -
taxicabDistanceTo(
Vector2 other) → double -
Available on Vector2, provided by the Vector2Extension extension
Distance toother
vector, using the taxicab (L1) geometry. -
toOffset(
) → Offset -
Available on Vector2, provided by the Vector2Extension extension
Creates an Offset from the Vector2 -
toPoint(
) → Point< num> -
Available on Vector2, provided by the Vector2Extension extension
Creates a Point from the Vector2 -
toPositionedRect(
Vector2 size) → Rect -
Available on Vector2, provided by the Vector2Extension extension
Creates a Rect starting from (x, y) and having the size of the argument Vector2 -
toRect(
) → Rect -
Available on Vector2, provided by the Vector2Extension extension
Creates a Rect starting in origin and going the Vector2 -
toSize(
) → Size -
Available on Vector2, provided by the Vector2Extension extension
Creates a Size from the Vector2 -
toStringWithMaxPrecision(
int maxPrecision) → String -
Available on Vector2, provided by the Vector2Extension extension
Stringifies the Vector2 with a maximum precision ofmaxPrecision
. -
translate(
double x, double y) → void -
Available on Vector2, provided by the Vector2Extension extension
Translates this Vector2 byx
andy
. -
translated(
double x, double y) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Creates a new Vector2 that is the current Vector2 translated byx
andy
.
Operators
-
operator %(
Vector2 mod) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Modulo/Remainder -
operator &(
Vector2 size) → Rect -
Available on Vector2, provided by the Vector2Extension extension
A rectangle constructor operator.
Static Methods
-
fromDegrees(
double d) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Creates a heading Vector2 with the given angle in degrees. -
fromInts(
int x, int y) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Create a Vector2 with ints as input -
fromRadians(
double r) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Creates a heading Vector2 with the given angle in radians. -
identity(
) → Vector2 -
Available on Vector2, provided by the Vector2Extension extension
Creates a new identity Vector2 (1.0, 1.0).