pub struct Camera2D {
pub rotation: f32,
pub zoom: Vec2,
pub target: Vec2,
pub offset: Vec2,
pub render_target: Option<RenderTarget>,
pub viewport: Option<(i32, i32, i32, i32)>,
}
Fields
rotation: f32
Rotation in degrees
zoom: Vec2
Scaling, should be (1.0, 1.0) by default
target: Vec2
Rotation and zoom origin
offset: Vec2
Displacement from target
render_target: Option<RenderTarget>
If “render_target” is set - camera will render to texture otherwise to the screen
viewport: Option<(i32, i32, i32, i32)>
Part of the screen to render to
None means the whole screen
Viewport do not affect camera space, just the render position on the screen
Usefull for things like splitscreen
Implementations
sourceimpl Camera2D
impl Camera2D
sourcepub fn from_display_rect(rect: Rect) -> Camera2D
pub fn from_display_rect(rect: Rect) -> Camera2D
Will make camera space equals given rect
sourceimpl Camera2D
impl Camera2D
sourcepub fn world_to_screen(&self, point: Vec2) -> Vec2
pub fn world_to_screen(&self, point: Vec2) -> Vec2
Returns the screen space position for a 2d camera world space position Screen position in window space - from (0, 0) to (screen_width, screen_height())
pub fn screen_to_world(&self, point: Vec2) -> Vec2
Trait Implementations
impl Copy for Camera2D
Auto Trait Implementations
impl RefUnwindSafe for Camera2D
impl Send for Camera2D
impl Sync for Camera2D
impl Unpin for Camera2D
impl UnwindSafe for Camera2D
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more