pub struct TransViewport { /* private fields */ }Expand description
Viewport transformer.
Maps world coordinates to device coordinates with optional aspect ratio
preservation. Can produce a TransAffine matrix for use with other
components.
Port of C++ trans_viewport.
Implementations§
Source§impl TransViewport
impl TransViewport
pub fn new() -> Self
Sourcepub fn preserve_aspect_ratio(
&mut self,
align_x: f64,
align_y: f64,
aspect: AspectRatio,
)
pub fn preserve_aspect_ratio( &mut self, align_x: f64, align_y: f64, aspect: AspectRatio, )
Set aspect ratio preservation mode and alignment.
Sourcepub fn set_device_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
pub fn set_device_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
Set the device (screen) viewport rectangle.
Sourcepub fn set_world_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
pub fn set_world_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
Set the world (logical) viewport rectangle.
Sourcepub fn world_viewport_actual(&self) -> (f64, f64, f64, f64)
pub fn world_viewport_actual(&self) -> (f64, f64, f64, f64)
Get the actual (computed) world viewport after aspect ratio adjustment.
pub fn is_valid(&self) -> bool
pub fn align_x(&self) -> f64
pub fn align_y(&self) -> f64
pub fn aspect_ratio(&self) -> AspectRatio
Sourcepub fn transform(&self, x: &mut f64, y: &mut f64)
pub fn transform(&self, x: &mut f64, y: &mut f64)
Transform world coordinates to device coordinates.
Sourcepub fn transform_scale_only(&self, x: &mut f64, y: &mut f64)
pub fn transform_scale_only(&self, x: &mut f64, y: &mut f64)
Transform only the scale component (no translation).
Sourcepub fn inverse_transform(&self, x: &mut f64, y: &mut f64)
pub fn inverse_transform(&self, x: &mut f64, y: &mut f64)
Transform device coordinates back to world coordinates.
Sourcepub fn inverse_transform_scale_only(&self, x: &mut f64, y: &mut f64)
pub fn inverse_transform_scale_only(&self, x: &mut f64, y: &mut f64)
Inverse transform only the scale component.
pub fn device_dx(&self) -> f64
pub fn device_dy(&self) -> f64
pub fn scale_x(&self) -> f64
pub fn scale_y(&self) -> f64
pub fn scale(&self) -> f64
Sourcepub fn to_affine(&self) -> TransAffine
pub fn to_affine(&self) -> TransAffine
Convert to an equivalent TransAffine matrix.
Sourcepub fn to_affine_scale_only(&self) -> TransAffine
pub fn to_affine_scale_only(&self) -> TransAffine
Convert to an affine matrix with only the scale component.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransViewport
impl RefUnwindSafe for TransViewport
impl Send for TransViewport
impl Sync for TransViewport
impl Unpin for TransViewport
impl UnwindSafe for TransViewport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more