Vector2Base<V2 extends Vector2Base<V2, M, V3, Q, V4>, M extends MatrixBase<M, V3, Q, V4>, V3 extends Vector3Base<V3, M, Q, V4>, Q extends QuaternionBase<Q, M, V3, V4>, V4 extends Vector4Base<V4, Q, M, V3>> mixin

Backend-agnostic contract for Vector2Base structs.

Must be mixed into every concrete platform implementation of a Raylib type to ensure a unified API surface across different backends.


A 2D vector with x and y components.

Superclass constraints

Properties

$state RaylibTempStructState
Per-instance allocation state tracking slot keys, disposal, and identity.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
length double
Euclidean length (magnitude) of this vector.
no setter
lengthSqr double
Squared length of this vector.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
structName String
The Dart-side type name of this struct
no setterinherited
x double
X component
getter/setter pair
y double
Y component
getter/setter pair

Methods

add(V2 o) → V2
Returns a new vector that is the component-wise sum of this and o.
addValue(num value) → V2
Returns a new vector with value added to each component.
angle(V2 o) double
Angle between this vector and o in radians.
clamp(V2 min, V2 max) → V2
Clamps each component of this vector between the corresponding components of min and max.
clampValue(double min, double max) → V2
Clamps the length of this vector to the range [min, max].
clone() → V2
Returns a deep copy of this instance, preserving RaylibStructBase.originalPointer if present.
inherited
copy() → V2
Returns a deep copy of this instance without RaylibStructBase.originalPointer.
inherited
distance(V2 o) double
Euclidean distance between this vector and o.
distanceSqr(V2 o) double
Squared Euclidean distance between this vector and o.
div(V2 o) → V2
Returns a new vector that is the component-wise quotient of this and o.
divideBy(num o) → V2
Returns a new vector with all components divided by o.
dotProduct(V2 o) double
Dot product of this vector and o.
equals(V2 o) bool
Returns true if this vector is approximately equal to o.
format([int x0 = 0, int? y0]) String
Returns a formatted string representation of this vector.
invert() → V2
Returns a new vector with each component replaced by its reciprocal (1/x, 1/y).
lerp(V2 o, double amount) → V2
Linear interpolation between this and o by amount.
lineAngle(V2 o) double
Angle of the line from this point to o, relative to the X axis.
max(V2 o) → V2
Returns a new vector with each component being the component-wise maximum of this and o.
min(V2 o) → V2
Returns a new vector with each component being the component-wise minimum of this and o.
moveTowards(V2 target, double maxDistance) → V2
Moves this vector towards target by at most maxDistance.
mul(V2 o) → V2
Returns a new vector that is the component-wise product of this and o.
negate() → V2
Returns a new vector with all components negated.
normalize() → V2
Returns a normalized (unit-length) copy of this vector.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reflect(V2 normal) → V2
Reflects this vector off a surface with the given normal.
refract(V2 n, double r) → V2
Refracts this vector through a surface with normal n and ratio r.
rotate(double angle) → V2
Rotates this vector by angle radians around the origin.
scale(num o) → V2
Returns a new vector with all components scaled by o.
set(num x, num y) → V2
Sets all components at once.
setD(V2 o) → V2
Copies the fields of o into this instance and returns this.
inherited
signature() String
Returns a human-readable representation of this struct.
override
sub(V2 o) → V2
Returns a new vector that is the component-wise difference of this and o.
subValue(num value) → V2
Returns a new vector with value subtracted from each component.
toArray() List<double>
Returns the components as a new double list.
toString() String
A string representation of this object.
inherited
transform(M o) → V2
Transforms this vector by matrix o.

Operators

operator ==(Object other) bool
The equality operator.
inherited