Struct sfml::graphics::View[][src]

#[repr(C)]pub struct View { /* fields omitted */ }

2D camera that defines what region is shown on screen

This is a very powerful concept: you can scroll, rotate or zoom the entire scene without altering the way that your drawable objects are drawn.

Implementations

impl View[src]

#[must_use]pub fn rotation(&self) -> f32[src]

Get the current orientation of a view

Return the rotation angle of the view, in degrees

#[must_use]pub fn center(&self) -> Vector2f[src]

Get the center of a view

Return the center of the view

#[must_use]pub fn size(&self) -> Vector2f[src]

Get the size of a view

Return the size of the view

#[must_use]pub fn viewport(&self) -> FloatRect[src]

Get the target viewport rectangle of a view

Return the viewport rectangle, expressed as a factor of the target size

#[must_use]pub fn new(center: Vector2f, size: Vector2f) -> SfBox<View>[src]

Creates a view with position and size

Arguments

  • center - The center of the view
  • size - The size of the view

#[must_use]pub fn from_rect(rectangle: &FloatRect) -> SfBox<View>[src]

Construct a view from a rectangle

Arguments

  • rectangle - The rectangle defining the zone to display

pub fn set_rotation(&mut self, angle: f32)[src]

Set the orientation of a view

The default rotation of a view is 0 degree.

Arguments

  • angle - New angle, in degrees

pub fn rotate(&mut self, angle: f32)[src]

Rotate a view relatively to its current orientation

Arguments

  • angle - Angle to rotate, in degrees

pub fn zoom(&mut self, factor: f32)[src]

Resize a view rectangle relatively to its current size

Resizing the view simulates a zoom, as the zone displayed on screen grows or shrinks.

factor is a multiplier:

  • 1 keeps the size unchanged
  • bigger than 1 makes the view bigger (objects appear smaller)
  • smaller than 1 makes the view smaller (objects appear bigger)

Arguments

  • factor - Zoom factor to apply

pub fn set_center<C: Into<Vector2f>>(&mut self, center: C)[src]

Set the center of a view

Arguments

  • center - New center

pub fn set_size<S: Into<Vector2f>>(&mut self, size: S)[src]

Set the size of a view

Arguments

  • size - New size of the view

pub fn move_<O: Into<Vector2f>>(&mut self, offset: O)[src]

Move a view relatively to its current position

Arguments

  • offset - Offset

pub fn set_viewport(&mut self, viewport: &FloatRect)[src]

Set the target viewport of a view

The viewport is the rectangle into which the contents of the view are displayed, expressed as a factor (between 0 and 1) of the size of the render target to which the view is applied. For example, a view which takes the left side of the target would be defined by a rect of (0, 0, 0.5, 1). By default, a view has a viewport which covers the entire target.

Arguments

  • viewport - New viewport rectangle

pub fn reset(&mut self, rectangle: &FloatRect)[src]

Reset a view to the given rectangle

Note that this function resets the rotation angle to 0.

Arguments

  • rectangle - Rectangle defining the zone to display

Trait Implementations

impl Debug for View[src]

impl ToOwned for View[src]

type Owned = SfBox<Self>

The resulting type after obtaining ownership.

Auto Trait Implementations

impl RefUnwindSafe for View

impl Send for View

impl Sync for View

impl Unpin for View

impl UnwindSafe for View

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.