localToGlobal method

Vector2 localToGlobal(
  1. Vector2 point, {
  2. Vector2? output,
})

Converts a point from the local coordinate system of the viewport to the global coordinate system.

Use output to send in a Vector2 object that will be used to avoid creating a new Vector2 object in this method.

Opposite of globalToLocal.

Implementation

Vector2 localToGlobal(Vector2 point, {Vector2? output}) {
  final x = point.x + position.x - anchor.x * size.x;
  final y = point.y + position.y - anchor.y * size.y;
  return (output?..setValues(x, y)) ?? Vector2(x, y);
}