viewportExtent property

Rect get viewportExtent

Gets the viewport extent as a Rect in world coordinates.

This represents the visible area of the graph in world space. Use this to determine which nodes or elements are currently visible.

Returns a Rect representing the visible portion of the graph in world coordinates.

Implementation

Rect get viewportExtent {
  final vp = _viewport.value;
  final size = _screenSize.value;

  // Convert screen bounds to world coordinates
  final left = -vp.x / vp.zoom;
  final top = -vp.y / vp.zoom;
  final right = (size.width - vp.x) / vp.zoom;
  final bottom = (size.height - vp.y) / vp.zoom;

  return Rect.fromLTRB(left, top, right, bottom);
}