CameraFit class

Immutable (tx, ty, scale) triple — a uniform-scale + translate 2D affine, the only shape used for both the host viewport-fit camera and the draw screen's local pinch/pan camera. Implements +, -, * so Animator<CameraFit> can interpolate it element-wise.

vector_math.Matrix4 * double is a geometric scale — it multiplies the rotation/scale columns only, leaving translation un-lerped. Driving an Animator<Matrix4> directly would snap translation to target on the first tick while scale lags, producing a visible "shrink-then-enlarge" detour. Animating CameraFit instead interpolates all three fields together.

Must be immutable: Animator's start captures the value returned from getter(). If the setter mutated a shared object, start would mutate alongside it, and subsequent ticks would compute prev + difference*curved instead of start + difference*curved, overshooting the target.

Constructors

CameraFit({required double tx, required double ty, required double scale})
A translation by (tx, ty) and a uniform scale.
const
CameraFit.fromMatrix(Matrix4 m)
Decompose a translate + uniform-scale Matrix4. Assumes the matrix has no rotation and m[0] == m[5] — true for the host camera and the draw viewer (both built by composing translate and uniform-scale only).
factory

Properties

hashCode → int
The hash code for this object.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scale → double
Uniform scale.
final
tx → double
Translation along x.
final
ty → double
Translation along y.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMatrix() → Matrix4
The affine as a matrix: scales by scale, then translates by (tx, ty).
toString() → String
A string representation of this object.
inherited

Operators

operator *(double s) → CameraFit
Every element times s.
operator +(CameraFit o) → CameraFit
The element-wise sum.
operator -(CameraFit o) → CameraFit
The element-wise difference.
operator ==(Object other) → bool
The equality operator.
override

Constants

identity → const CameraFit
(0, 0, 1) — the identity transform. Target for "reset to un-zoomed baseline" animations (e.g. draw screen viewerCamera on close).
zero → const CameraFit
(0, 0, 0) — the additive zero. Used as the seed for the host cameraAnimator before the first fit is published.