toGraph method
Transforms a ScreenPosition to a GraphPosition.
Converts a position in screen pixels to the corresponding position in the graph's coordinate space, accounting for pan and zoom.
Example:
final viewport = GraphViewport(x: 100, y: 50, zoom: 2.0);
final screenPos = ScreenPosition.fromXY(200, 150);
final graphPos = viewport.toGraph(screenPos);
// Returns: GraphPosition(50, 50)
Implementation
GraphPosition toGraph(ScreenPosition screenPoint) {
return GraphPosition(
Offset((screenPoint.dx - x) / zoom, (screenPoint.dy - y) / zoom),
);
}