pub struct Viewport {
pub width: u32,
pub height: u32,
pub safe_area: Rect,
pub aspect_ratio: AspectRatio,
}Expand description
Viewport representing the rendering area
Fields§
§width: u32Width in pixels
height: u32Height in pixels
safe_area: RectSafe area for gameplay (16:9 within any aspect ratio)
aspect_ratio: AspectRatioDetected aspect ratio
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn screen_to_world(&self, screen_pos: Vec2, camera: &Camera) -> Vec2
pub fn screen_to_world(&self, screen_pos: Vec2, camera: &Camera) -> Vec2
Converts screen coordinates to world coordinates
Sourcepub fn world_to_screen(&self, world_pos: Vec2, camera: &Camera) -> Vec2
pub fn world_to_screen(&self, world_pos: Vec2, camera: &Camera) -> Vec2
Converts world coordinates to screen coordinates
Sourcepub fn is_visible(&self, world_pos: Vec2, camera: &Camera) -> bool
pub fn is_visible(&self, world_pos: Vec2, camera: &Camera) -> bool
Checks if a world position is visible
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Viewport
impl<'de> Deserialize<'de> for Viewport
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Viewport
Auto Trait Implementations§
impl Freeze for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin 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