toGraphOffset method

GraphOffset toGraphOffset(
  1. ScreenOffset screenOffset
)

Transforms a ScreenOffset to a GraphOffset.

Converts a change in screen position to the corresponding change in graph coordinates. Unlike toGraph, this only applies zoom scaling, not pan translation.

Useful for converting mouse drag distances to graph movement.

Example:

final viewport = GraphViewport(zoom: 2.0);
final screenDrag = ScreenOffset.fromXY(100, 50);
final graphDrag = viewport.toGraphOffset(screenDrag);
// Returns: GraphOffset(50, 25)

Implementation

GraphOffset toGraphOffset(ScreenOffset screenOffset) {
  return GraphOffset(Offset(screenOffset.dx / zoom, screenOffset.dy / zoom));
}