MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
size.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace mbgl {
6 
7 class Size {
8 public:
9  constexpr Size() = default;
10 
11  constexpr Size(const uint32_t width_, const uint32_t height_) : width(width_), height(height_) {
12  }
13 
14  constexpr uint32_t area() const {
15  return width * height;
16  }
17 
18  constexpr float aspectRatio() const {
19  return static_cast<float>(width) / static_cast<float>(height);
20  }
21 
22  constexpr bool isEmpty() const {
23  return width == 0 || height == 0;
24  }
25 
26  uint32_t width = 0;
27  uint32_t height = 0;
28 };
29 
30 constexpr inline bool operator==(const Size& a, const Size& b) {
31  return a.width == b.width && a.height == b.height;
32 }
33 
34 constexpr inline bool operator!=(const Size& a, const Size& b) {
35  return !(a == b);
36 }
37 
38 } // namespace mbgl
constexpr uint32_t area() const
Definition: size.hpp:14
constexpr float aspectRatio() const
Definition: size.hpp:18
constexpr Size(const uint32_t width_, const uint32_t height_)
Definition: size.hpp:11
uint32_t width
Definition: size.hpp:26
uint32_t height
Definition: size.hpp:27
constexpr Size()=default
constexpr bool isEmpty() const
Definition: size.hpp:22
Definition: actor.hpp:15
constexpr bool operator==(const CameraOptions &a, const CameraOptions &b)
Definition: camera.hpp:50
constexpr bool operator!=(const CameraOptions &a, const CameraOptions &b)
Definition: camera.hpp:59