GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Rectangle.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef RADIX_RECTANGLE_HPP
3 #define RADIX_RECTANGLE_HPP
4 
5 namespace radix {
6 
9 template<typename T>
10 struct Rectangle {
11  T x, y, w, h;
12 
13  /* Core */
14  constexpr Rectangle() {}
15  constexpr Rectangle(T x, T y, T w, T h) :
16  x(x), y(y), w(w), h(h) {}
17 
18  constexpr void set(T x, T y, T w, T h) {
19  this->x = x;
20  this->y = y;
21  this->w = w;
22  this->h = h;
23  }
24 
25  constexpr bool hasZeroArea() const {
26  return w == 0 and h == 0;
27  }
28 
29  /* Operator overloads */
30  constexpr bool operator==(const Rectangle<T> &o) const {
31  return x == o.x and
32  y == o.y and
33  w == o.w and
34  h == o.h;
35  }
36  constexpr bool operator!=(const Rectangle<T> &o) const {
37  return !operator==(o);
38  }
39 };
40 
44 
45 } /* namespace radix */
46 
47 #endif /* RADIX_RECTANGLE_HPP */
Definition: GameController.hpp:7
constexpr bool operator==(const Rectangle< T > &o) const
Definition: Rectangle.hpp:30
Definition: Rectangle.hpp:10
T y
Definition: Rectangle.hpp:11
T h
Definition: Rectangle.hpp:11
constexpr bool operator!=(const Rectangle< T > &o) const
Definition: Rectangle.hpp:36
constexpr Rectangle(T x, T y, T w, T h)
Definition: Rectangle.hpp:15
constexpr void set(T x, T y, T w, T h)
Definition: Rectangle.hpp:18
constexpr bool hasZeroArea() const
Definition: Rectangle.hpp:25
constexpr Rectangle()
Definition: Rectangle.hpp:14
T x
Definition: Rectangle.hpp:11
T w
Definition: Rectangle.hpp:11