toImageSpace static method

Offset toImageSpace(
  1. Offset viewport,
  2. Matrix4 camera
)

Convert a viewport-space pointer position to image-space using the host camera (uniform scale + translate, no rotate).

Implementation

static Offset toImageSpace(Offset viewport, vmath.Matrix4 camera) {
  final scale = camera.storage[0];
  final tx = camera.storage[12];
  final ty = camera.storage[13];
  return Offset((viewport.dx - tx) / scale, (viewport.dy - ty) / scale);
}