pub struct Camera2D {
pub position: Vector2D,
pub zoom: f64,
pub rotation: f64,
pub viewport_width: f64,
pub viewport_height: f64,
}Expand description
A 2D camera that defines the viewport into the game world.
Fields§
§position: Vector2DThe world-space position of the camera center.
zoom: f64The zoom factor (1.0 = no zoom, 2.0 = 2x magnification).
rotation: f64The rotation angle in radians.
viewport_width: f64The viewport width in screen pixels.
viewport_height: f64The viewport height in screen pixels.
Implementations§
Source§impl Camera2D
Implements camera transformation methods for Camera2D.
impl Camera2D
Implements camera transformation methods for Camera2D.
Sourcepub fn world_to_screen(&self, world: Vector2D) -> Vector2D
pub fn world_to_screen(&self, world: Vector2D) -> Vector2D
Sourcepub fn screen_to_world(&self, screen: Vector2D) -> Vector2D
pub fn screen_to_world(&self, screen: Vector2D) -> Vector2D
Source§impl Camera2D
impl Camera2D
pub fn get_position(&self) -> Vector2D
pub fn set_position(&mut self, val: Vector2D) -> &mut Self
pub fn get_zoom(&self) -> f64
pub fn set_zoom(&mut self, val: f64) -> &mut Self
pub fn get_rotation(&self) -> f64
pub fn set_rotation(&mut self, val: f64) -> &mut Self
pub fn get_viewport_width(&self) -> f64
pub fn get_viewport_height(&self) -> f64
Trait Implementations§
impl Copy for Camera2D
Source§impl Default for Camera2D
Implements Default for Camera2D as a camera at the origin with 800x600 viewport.
impl Default for Camera2D
Implements Default for Camera2D as a camera at the origin with 800x600 viewport.
Source§impl PartialOrd for Camera2D
impl PartialOrd for Camera2D
impl StructuralPartialEq for Camera2D
Auto Trait Implementations§
impl Freeze for Camera2D
impl RefUnwindSafe for Camera2D
impl Send for Camera2D
impl Sync for Camera2D
impl Unpin for Camera2D
impl UnsafeUnpin for Camera2D
impl UnwindSafe for Camera2D
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