[−][src]Struct tetra::graphics::Camera
A camera that can be used to transform the scene.
Fields
position: Vec2<f32>
The position of the camera.
rotation: f32
The rotation of the camera, in radians.
zoom: f32
The zoom level of the camera.
viewport_width: f32
The width of the camera's viewport.
viewport_height: f32
The height of the camera's viewport.
Methods
impl Camera
[src]
pub fn new(viewport_width: f32, viewport_height: f32) -> Camera
[src]
Creates a new camera.
pub fn with_window_size(ctx: &Context) -> Camera
[src]
Creates a new camera, with the viewport size set to match the window.
If the window is resizable, make sure that you call set_viewport_size
when
the size changes!
pub fn set_viewport_size(&mut self, width: f32, height: f32)
[src]
Sets the size of the camera's viewport.
pub fn update(&mut self)
[src]
Recalculates the transformation matrix, based on the data currently contained within the camera.
pub fn as_matrix(&self) -> Mat4<f32>
[src]
Returns the current transformation matrix.
Pass this to graphics::set_transform_matrix
to apply the transformation to
your scene!
pub fn project(&self, point: Vec2<f32>) -> Vec2<f32>
[src]
Projects a point from screen co-ordinates to camera co-ordinates.
pub fn unproject(&self, point: Vec2<f32>) -> Vec2<f32>
[src]
Projects a point from camera co-ordinates to screen co-ordinates.
pub fn mouse_position(&self, ctx: &Context) -> Vec2<f32>
[src]
Returns the mouse's position in camera space.
This is a shortcut for calling project(input::get_mouse_position(ctx))
.
pub fn mouse_x(&self, ctx: &Context) -> f32
[src]
Returns the X co-ordinate of the mouse's position in camera space.
This is a shortcut for calling project(input::get_mouse_position(ctx)).x
.
pub fn mouse_y(&self, ctx: &Context) -> f32
[src]
Returns the Y co-ordinate of the mouse's position in camera space.
This is a shortcut for calling project(input::get_mouse_position(ctx)).y
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Camera
impl Send for Camera
impl Sync for Camera
impl Unpin for Camera
impl UnwindSafe for Camera
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,