pub struct ViewportMapping {
pub content_rect: Rect,
pub target_px_size: (u32, u32),
pub fit: ViewportFit,
}Fields§
§content_rect: Rect§target_px_size: (u32, u32)§fit: ViewportFitImplementations§
Source§impl ViewportMapping
impl ViewportMapping
pub fn map(self) -> ViewportMapped
Sourcepub fn target_px_per_screen_px(self) -> Option<f32>
pub fn target_px_per_screen_px(self) -> Option<f32>
Returns the scale from window-local logical pixels (“screen px”) to render-target pixels.
This is derived from the mapped draw rect (logical pixels) and the backing render target
size self.target_px_size (physical pixels).
For ViewportFit::Contain/Cover this is uniform; for ViewportFit::Stretch the mapping
is non-uniform, so this returns the smaller axis scale as a conservative approximation for
isotropic thresholds (hit radii, click distances).
pub fn window_point_to_uv(self, p: Point) -> Option<(f32, f32)>
pub fn window_point_to_uv_clamped(self, p: Point) -> (f32, f32)
pub fn window_point_to_target_px(self, p: Point) -> Option<(u32, u32)>
pub fn window_point_to_target_px_clamped(self, p: Point) -> (u32, u32)
Trait Implementations§
Source§impl Clone for ViewportMapping
impl Clone for ViewportMapping
Source§fn clone(&self) -> ViewportMapping
fn clone(&self) -> ViewportMapping
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ViewportMapping
impl Debug for ViewportMapping
Source§impl PartialEq for ViewportMapping
impl PartialEq for ViewportMapping
impl Copy for ViewportMapping
impl StructuralPartialEq for ViewportMapping
Auto Trait Implementations§
impl Freeze for ViewportMapping
impl RefUnwindSafe for ViewportMapping
impl Send for ViewportMapping
impl Sync for ViewportMapping
impl Unpin for ViewportMapping
impl UnsafeUnpin for ViewportMapping
impl UnwindSafe for ViewportMapping
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