textEntityViewPose function
({double rotation, double scale})
textEntityViewPose({
- Matrix4? viewerCamera,
- CropImageLayer? crop,
Rotation and scale for a new text overlay so it appears upright at viewport-native size through the draw editor's view transform (viewer pan/zoom × crop imageTransform).
Implementation
({double rotation, double scale}) textEntityViewPose({
vmath.Matrix4? viewerCamera,
CropImageLayer? crop,
}) {
var scale = 1.0;
var rotation = 0.0;
final viewer = viewerCamera?.storage[0] ?? 1.0;
if (viewer.abs() > 1e-9) scale /= viewer.abs();
if (crop != null && crop.hasAppliedEdits) {
final t = crop.imageTransform;
if (t.totalScale.abs() > 1e-9) scale /= t.totalScale.abs();
rotation = -t.totalRotate;
}
return (rotation: rotation, scale: scale);
}