screenAngle method

double screenAngle()

Signed angle in a coordinate system where the Y-axis is flipped.

Since on a canvas/screen y is smaller the further up you go, instead of larger like on a normal coordinate system, to get an angle that is in that coordinate system we have to flip the Y-axis of the Vector2.

Example: Up: Vector(0.0, -1.0).screenAngle == 0 Down: Vector(0.0, 1.0).screenAngle == +-pi Left: Vector(-1.0, 0.0).screenAngle == -pi/2 Right: Vector(-1.0, 0.0).screenAngle == pi/2

Implementation

double screenAngle() => (_reusableVector..setValues(x, y * (-1)))
    .angleToSigned(Vector2(0.0, 1.0));