FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_rect.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_RECT_HPP_INCLUDED
18#define _FGE_C_RECT_HPP_INCLUDED
19
20/*
21 * Original from : https://github.com/SFML/SFML
22 * Copyright (C) 2007-2022 Laurent Gomila
23 *
24 * Altered/Modified by Guillaume Guillet
25 */
26
27#include "C_vector.hpp"
28#include <optional>
29#include <type_traits>
30
31namespace fge
32{
33
34template<class T>
35class Rect
36{
37 static_assert(std::is_arithmetic_v<T>, "T must be arithmetic !");
38
39public:
40 Rect();
41 Rect(Vector2<T> const& position, Vector2<T> const& size);
42
43 template<class U>
44 explicit Rect(Rect<U> const& rectangle);
45
46 [[nodiscard]] bool operator==(Rect<T> const& right) const;
47 [[nodiscard]] bool operator!=(Rect<T> const& right) const;
48
49 [[nodiscard]] bool contains(Vector2<T> const& point) const;
50 [[nodiscard]] std::optional<Rect<T>> findIntersection(Rect<T> const& rectangle) const;
51
52 [[nodiscard]] Vector2<T> getPosition() const;
53 [[nodiscard]] Vector2<T> getSize() const;
54
55 T _x;
56 T _y;
57 T _width;
58 T _height;
59};
60
64
65fge::RectFloat operator*(glm::mat4 const& left, fge::RectFloat const& right);
66
67} // namespace fge
68
69#include "C_rect.inl"
70
71#endif //_FGE_C_RECT_HPP_INCLUDED
Definition C_rect.hpp:36