Struct sfml::graphics::View

source ·
#[repr(C)]
pub struct View { /* private fields */ }
Expand description

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§

Get the current orientation of a view

Return the rotation angle of the view, in degrees

Get the center of a view

Return the center of the view

Get the size of a view

Return the size of the view

Get the target viewport rectangle of a view

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

Creates a view with position and size

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

Construct a view from a rectangle

Arguments
  • rectangle - The rectangle defining the zone to display

Set the orientation of a view

The default rotation of a view is 0 degree.

Arguments
  • angle - New angle, in degrees

Rotate a view relatively to its current orientation

Arguments
  • angle - Angle to rotate, in degrees

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

Set the center of a view

Arguments
  • center - New center

Set the size of a view

Arguments
  • size - New size of the view

Move a view relatively to its current position

Arguments
  • offset - Offset

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

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§

Formats the value using the given formatter. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.