pub struct Viewport {
pub zoom: f32,
pub cx: f64,
pub cy: f64,
pub rect: [i32; 4],
pub dpi: i32,
}Expand description
what part of the world the canvas shows: zoom (DIP per world unit, 1 = 100 %), the world point at the centre of rect; rect (absolute px) and dpi are kept by ui.diagram
Fields§
§zoom: f32§cx: f64§cy: f64§rect: [i32; 4]§dpi: i32Implementations§
Source§impl Viewport
impl Viewport
pub const ZOOM_MIN: f32 = 0.1
pub const ZOOM_MAX: f32 = 8.0
Sourcepub fn world_rect(&self) -> [f32; 4]
pub fn world_rect(&self) -> [f32; 4]
the world rectangle x0, y0, x1, y1 the canvas shows
Sourcepub fn rect_to_screen(&self, r: [f32; 4]) -> [f32; 4]
pub fn rect_to_screen(&self, r: [f32; 4]) -> [f32; 4]
a world rectangle x, y, w, h in px (x, y, w, h, fractional)
Sourcepub fn zoom_at(&mut self, zoom: f32, sx: f32, sy: f32)
pub fn zoom_at(&mut self, zoom: f32, sx: f32, sy: f32)
zoom (clamped) keeping the world point under the absolute px (sx, sy) in place
Trait Implementations§
impl Copy for Viewport
impl StructuralPartialEq for Viewport
Auto Trait Implementations§
impl Forget for Viewport
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
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