Skip to main content

TransViewport

Struct TransViewport 

Source
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

Source

pub fn new() -> Self

Source

pub fn preserve_aspect_ratio( &mut self, align_x: f64, align_y: f64, aspect: AspectRatio, )

Set aspect ratio preservation mode and alignment.

Source

pub fn set_device_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)

Set the device (screen) viewport rectangle.

Source

pub fn set_world_viewport(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)

Set the world (logical) viewport rectangle.

Source

pub fn device_viewport(&self) -> (f64, f64, f64, f64)

Get the device viewport rectangle.

Source

pub fn world_viewport(&self) -> (f64, f64, f64, f64)

Get the world viewport rectangle.

Source

pub fn world_viewport_actual(&self) -> (f64, f64, f64, f64)

Get the actual (computed) world viewport after aspect ratio adjustment.

Source

pub fn is_valid(&self) -> bool

Source

pub fn align_x(&self) -> f64

Source

pub fn align_y(&self) -> f64

Source

pub fn aspect_ratio(&self) -> AspectRatio

Source

pub fn transform(&self, x: &mut f64, y: &mut f64)

Transform world coordinates to device coordinates.

Source

pub fn transform_scale_only(&self, x: &mut f64, y: &mut f64)

Transform only the scale component (no translation).

Source

pub fn inverse_transform(&self, x: &mut f64, y: &mut f64)

Transform device coordinates back to world coordinates.

Source

pub fn inverse_transform_scale_only(&self, x: &mut f64, y: &mut f64)

Inverse transform only the scale component.

Source

pub fn device_dx(&self) -> f64

Source

pub fn device_dy(&self) -> f64

Source

pub fn scale_x(&self) -> f64

Source

pub fn scale_y(&self) -> f64

Source

pub fn scale(&self) -> f64

Source

pub fn to_affine(&self) -> TransAffine

Convert to an equivalent TransAffine matrix.

Source

pub fn to_affine_scale_only(&self) -> TransAffine

Convert to an affine matrix with only the scale component.

Trait Implementations§

Source§

impl Default for TransViewport

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.