bakeViewerTransform method
void
bakeViewerTransform()
Compose the user's compose-page pan/zoom (held by viewerController
from the InteractiveViewer) into camera and reset the viewer to
identity. Called by ComposePage._openTool so the tool screen's
cameraAnimator starts from what the user is currently looking
at — pre-fix the camera was still at the original fit and the
image visibly snapped back when crop / draw mounted.
Implementation
void bakeViewerTransform() {
final v = viewerController.value;
final vs = v.storage[0];
final vx = v.storage[12];
final vy = v.storage[13];
if (vs == 1.0 && vx == 0 && vy == 0) return;
cameraAnimator.cancel();
final composed = CameraFit(
tx: vx + vs * _animatedFit.tx,
ty: vy + vs * _animatedFit.ty,
scale: vs * _animatedFit.scale,
);
_animatedFit = composed;
camera.value = composed.toMatrix();
viewerController.value = vmath.Matrix4.identity();
}