worldToScreen method

Vector2 worldToScreen(
  1. Vector2 argWorld
)

Takes the world coordinates and return the corresponding screen coordinates.

Implementation

Vector2 worldToScreen(Vector2 argWorld) {
  // Correct for canvas considering the upper-left corner, rather than the
  // center, to be the origin.
  final gridCorrected = Vector2(
    (argWorld.x * scale) + extents.x,
    extents.y - (argWorld.y * scale),
  );
  return gridCorrected + (translation..y *= (yFlip ? 1 : -1));
}