Documentation de SFML 2.6.1

Loading...
Searching...
No Matches
View.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_VIEW_HPP
26#define SFML_VIEW_HPP
27
29// Headers
31#include <SFML/Graphics/Export.hpp>
32#include <SFML/Graphics/Rect.hpp>
33#include <SFML/Graphics/Transform.hpp>
34#include <SFML/System/Vector2.hpp>
35
36
37namespace sf
38{
43class SFML_GRAPHICS_API View
44{
45public:
46
54
61 explicit View(const FloatRect& rectangle);
62
70 View(const Vector2f& center, const Vector2f& size);
71
81 void setCenter(float x, float y);
82
91 void setCenter(const Vector2f& center);
92
102 void setSize(float width, float height);
103
112 void setSize(const Vector2f& size);
113
124 void setRotation(float angle);
125
141 void setViewport(const FloatRect& viewport);
142
153 void reset(const FloatRect& rectangle);
154
163 const Vector2f& getCenter() const;
164
173 const Vector2f& getSize() const;
174
183 float getRotation() const;
184
193 const FloatRect& getViewport() const;
194
204 void move(float offsetX, float offsetY);
205
214 void move(const Vector2f& offset);
215
224 void rotate(float angle);
225
241 void zoom(float factor);
242
253 const Transform& getTransform() const;
254
266
267private:
268
270 // Member data
272 Vector2f m_center;
273 Vector2f m_size;
274 float m_rotation;
275 FloatRect m_viewport;
276 mutable Transform m_transform;
277 mutable Transform m_inverseTransform;
278 mutable bool m_transformUpdated;
279 mutable bool m_invTransformUpdated;
280};
281
282} // namespace sf
283
284
285#endif // SFML_VIEW_HPP
286
287
Define a 3x3 transform matrix.
Definition Transform.hpp:43
2D camera that defines what region is shown on screen
Definition View.hpp:44
void move(float offsetX, float offsetY)
Move the view relatively to its current position.
View(const FloatRect &rectangle)
Construct the view from a rectangle.
void setRotation(float angle)
Set the orientation of the view.
View()
Default constructor.
float getRotation() const
Get the current orientation of the view.
void zoom(float factor)
Resize the view rectangle relatively to its current size.
void move(const Vector2f &offset)
Move the view relatively to its current position.
const Vector2f & getSize() const
Get the size of the view.
void rotate(float angle)
Rotate the view relatively to its current orientation.
const Vector2f & getCenter() const
Get the center of the view.
void setViewport(const FloatRect &viewport)
Set the target viewport.
void setSize(float width, float height)
Set the size of the view.
void setSize(const Vector2f &size)
Set the size of the view.
const FloatRect & getViewport() const
Get the target viewport rectangle of the view.
const Transform & getInverseTransform() const
Get the inverse projection transform of the view.
void setCenter(float x, float y)
Set the center of the view.
void setCenter(const Vector2f &center)
Set the center of the view.
void reset(const FloatRect &rectangle)
Reset the view to the given rectangle.
const Transform & getTransform() const
Get the projection transform of the view.
View(const Vector2f &center, const Vector2f &size)
Construct the view from its center and size.