Placement
pub struct Placement
Where one camera's frame sits in view space.
A 3×3 affine transform: zoom, rotation, and where the frame's centre
lands. Construct with Placement::identity or
Placement::centred; the underlying struct is versioned and
carries its own size, so it has to be initialised through the ABI
rather than zeroed.
Placement — methods
pub fn identity() -> Result<Self>
A placement that moves nothing.
pub fn centred(
A frame centred on at, zoomed and rotated about itself.
pub fn matrix(&self) -> [f32; 9]
The nine coefficients of the transform, row by row.
pub fn zoom(&self) -> Result<f32>
Output pixels per camera pixel.
pub fn rotation_deg(&self) -> Result<f32>
Rotation in degrees, anticlockwise.
pub fn frame_centre(&self, frame_width: u32, frame_height: u32) -> Result<Vec2>
Where this frame's centre lands.
pub fn has_shear(&self) -> Result<bool>
Whether the transform shears.
A placement built by this module never does; one read back out of a canvas somebody else composed may.
pub fn is_identity(&self) -> Result<bool>
Whether this placement moves nothing.
pub fn inverse(&self) -> Result<Option<[f32; 9]>>
The inverse transform's nine coefficients, or None.
None when the transform cannot be inverted: a zero zoom, or a
degenerate matrix read back from somewhere else. The ABI reports
that through a flag beside the matrix, and this is an Option
rather than nine numbers nobody should use: a value in the value
space cannot be told apart from a real answer.
pub fn set_zoom(&mut self, zoom: f32, frame_width: u32, frame_height: u32) -> Result<()>
Set the zoom, keeping the frame's centre where it is.
pub fn set_rotation_deg(
Set the rotation, keeping the frame's centre where it is.
pub fn set_frame_centre(
Move the frame's centre to at.
pub fn pan(&mut self, delta: impl Into<Vec2>) -> Result<()>
Shift the frame by delta.
Needs no frame size: a pan is a translation in view space and does not depend on how big the camera's picture is.