# SFML - Simple and Fast Multimedia Library

SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Transform.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 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#pragma once
26
28// Headers
30#include <SFML/Graphics/Export.hpp>
31
32#include <SFML/Graphics/Rect.hpp>
33
34#include <SFML/System/Vector2.hpp>
35
36#include <array>
37
38
39namespace sf
40{
41class Angle;
42
47 class Transform
48{
49public:
56 constexpr Transform() = default;
57
72 constexpr Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22);
73
89 [[nodiscard]] constexpr const float* getMatrix() const;
90
100 [[nodiscard]] constexpr Transform getInverse() const;
101
116 [[nodiscard]] constexpr Vector2f transformPoint(Vector2f point) const;
117
132 [[nodiscard]] constexpr FloatRect transformRect(const FloatRect& rectangle) const;
133
152 constexpr Transform& combine(const Transform& transform);
153
171 constexpr Transform& translate(Vector2f offset);
172
190 SFML_GRAPHICS_API Transform& rotate(Angle angle);
191
215 SFML_GRAPHICS_API Transform& rotate(Angle angle, Vector2f center);
216
234 constexpr Transform& scale(Vector2f factors);
235
259 constexpr Transform& scale(Vector2f factors, Vector2f center);
260
262 // Static member data
264 // NOLINTNEXTLINE(readability-identifier-naming)
265 static const Transform Identity;
266
267private:
269 // Member data
271 // clang-format off
272 std::array<float, 16> m_matrix{1.f, 0.f, 0.f, 0.f,
273 0.f, 1.f, 0.f, 0.f,
274 0.f, 0.f, 1.f, 0.f,
275 0.f, 0.f, 0.f, 1.f};
276 // clang-format off
277};
278
291[[nodiscard]] constexpr Transform operator*(const Transform& left, const Transform& right);
292
305 constexpr Transform& operator*=(Transform& left, const Transform& right);
306
319[[nodiscard]] constexpr Vector2f operator*(const Transform& left, Vector2f right);
320
334[[nodiscard]] constexpr bool operator==(const Transform& left, const Transform& right);
335
348[[nodiscard]] constexpr bool operator!=(const Transform& left, const Transform& right);
349
350} // namespace sf
351
352#include <SFML/Graphics/Transform.inl>
353
354
Export.hpp
SFML_GRAPHICS_API
#define SFML_GRAPHICS_API
Definition Graphics/Export.hpp:42
Rect.hpp
Vector2.hpp
sf::Angle
Represents an angle value.
Definition Angle.hpp:35
sf::Rect< float >
sf::Transform
3x3 transform matrix
Definition Transform.hpp:48
sf::Transform::operator*
constexpr Vector2f operator*(const Transform &left, Vector2f right)
Overload of binary operator* to transform a point.
sf::Transform::operator*=
constexpr Transform & operator*=(Transform &left, const Transform &right)
Overload of binary operator*= to combine two transforms.
sf::Transform::Transform
constexpr Transform(float a00, float a01, float a02, float a10, float a11, float a12, float a20, float a21, float a22)
Construct a transform from a 3x3 matrix.
sf::Transform::transformPoint
constexpr Vector2f transformPoint(Vector2f point) const
Transform a 2D point.
sf::Transform::scale
constexpr Transform & scale(Vector2f factors, Vector2f center)
Combine the current transform with a scaling.
sf::Transform::operator!=
constexpr bool operator!=(const Transform &left, const Transform &right)
Overload of binary operator!= to compare two transforms.
sf::Transform::rotate
Transform & rotate(Angle angle)
Combine the current transform with a rotation.
sf::Transform::Transform
constexpr Transform()=default
Default constructor.
sf::Transform::transformRect
constexpr FloatRect transformRect(const FloatRect &rectangle) const
Transform a rectangle.
sf::Transform::translate
constexpr Transform & translate(Vector2f offset)
Combine the current transform with a translation.
sf::Transform::operator==
constexpr bool operator==(const Transform &left, const Transform &right)
Overload of binary operator== to compare two transforms.
sf::Transform::Identity
static const Transform Identity
The identity transform (does nothing)
Definition Transform.hpp:265
sf::Transform::scale
constexpr Transform & scale(Vector2f factors)
Combine the current transform with a scaling.
sf::Transform::rotate
Transform & rotate(Angle angle, Vector2f center)
Combine the current transform with a rotation.
sf::Transform::combine
constexpr Transform & combine(const Transform &transform)
Combine the current transform with another one.
sf::Transform::getInverse
constexpr Transform getInverse() const
Return the inverse of the transform.
sf::Transform::getMatrix
constexpr const float * getMatrix() const
Return the transform as a 4x4 matrix.
sf::Transform::operator*
constexpr Transform operator*(const Transform &left, const Transform &right)
Overload of binary operator* to combine two transforms.
sf::Vector2< float >
sf
Definition AudioResource.hpp:36