worldToScreen method

Offset worldToScreen(
  1. Offset worldPoint
)

Converts a world coordinate point to screen coordinates.

Use this to transform positions in graph space to screen space, taking into account the current viewport position and zoom level.

Parameters:

  • worldPoint: The point in world/graph coordinates

Returns the corresponding point in screen coordinates.

Example:

final nodePos = Offset(100, 100); // Position in graph
final screenPos = controller.worldToScreen(nodePos); // Position on screen

Implementation

Offset worldToScreen(Offset worldPoint) {
  final vp = _viewport.value;
  return Offset(
    worldPoint.dx * vp.zoom + vp.x,
    worldPoint.dy * vp.zoom + vp.y,
  );
}