View on GitHub

DSFML

dsfml.graphics.view



class View;
2D camera that defines what region is shown on screen

View defines a camera in the 2D scene.

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.

A view is composed of a source rectangle, which defines what part of the 2D scene is shown, and a target viewport, which defines where the contents of the source rectangle will be displayed on the render target (window or texture).

The viewport allows to map the scene to a custom part of the render target, and can be used for split-screen or for displaying a minimap, for example. If the source rectangle has not the same size as the viewport, its contents will be stretched to fit in.

To apply a view, you have to assign it to the render target. Then, every objects drawn in this render target will be affected by the view until you use another view.

Authors:
Laurent Gomila, Jeremy DeHaan

See Also:


http:
//www.sfml-dev.org/documentation/2.0/classsf_1_1View.php#details

@property Vector2f center(Vector2f newCenter);
The center of the view.

const @property Vector2f center();
The center of the view.

@property float rotation(float newRotation);
The orientation of the view, in degrees. The default rotation is 0 degrees.

const @property float rotation();
The orientation of the view, in degrees. The default rotation is 0 degrees.

@property Vector2f size(Vector2f newSize);
The size of the view. The default size is (1, 1).

const @property Vector2f size();
The size of the view. The default size is (1, 1).

@property FloatRect viewport(FloatRect newTarget);
The target viewpoirt.

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 RenderTarget to which the view is applied. For example, a view which takes the left side of the target would be defined with View.setViewport(FloatRect(0, 0, 0.5, 1)). By default, a view has a viewport which covers the entire target.

const @property FloatRect viewport();
The target viewpoirt.

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 RenderTarget to which the view is applied. For example, a view which takes the left side of the target would be defined with View.setViewport(FloatRect(0, 0, 0.5, 1)). By default, a view has a viewport which covers the entire target.

const @property View dup();
Performs a deep copy of the view.

Returns:
Duplicated view.

void move(Vector2f offset);
Move the view relatively to its current position.

Params:
Vector2f offset Move offset

void reset(FloatRect rectangle);
Reset the view to the given rectangle.

Note that this function resets the rotation angle to 0.

Params:
FloatRect rectangle Rectangle defining the zone to display.

void zoom(float factor);
Resize the 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. - > 1 makes the view bigger (objects appear smaller). - < 1 makes the view smaller (objects appear bigger).

Params:
float factor Zoom factor to apply.